Telegram Group & Telegram Channel
golang deep comparison for testing:

https://github.com/maxawww.tg-me.com/go-testdeep

import (
"testing"
"time"
)

func TestCreateRecord(t *testing.T) {
before := time.Now().Truncate(time.Second)
record, err := CreateRecord()

if err != nil {
t.Errorf("An error occurred: %s", err)
} else {
expected := Record{Name: "Bob", Age: 23}

if record.Id == 0 {
t.Error("Id probably not initialized")
}
if before.After(record.CreatedAt) ||
time.Now().Before(record.CreatedAt) {
t.Errorf("CreatedAt field not expected: %s", record.CreatedAt)
}
if record.Name != expected.Name {
t.Errorf("Name field differs, got=%s, expected=%s",
record.Name, expected.Name)
}
if record.Age != expected.Age {
t.Errorf("Age field differs, got=%s, expected=%s",
record.Age, expected.Age)
}
}
}

можно переписать в:
import (
"testing"
"time"

"github.com/maxawww.tg-me.com/go-testdeep/td"
)

func TestCreateRecord(t *testing.T) {
before := time.Now().Truncate(time.Second)
record, err := CreateRecord()

if td.CmpNoError(t, err) {
td.Cmp(t, record.Id, td.NotZero(), "Id initialized")
td.Cmp(t, record.Name, "Bob")
td.Cmp(t, record.Age, 23)
td.Cmp(t, record.CreatedAt, td.Between(before, time.Now()))
}
}


P.S. в проде не юзал но выглядит аккуратно, особенно когда происходит расхождение с ожидаемым результатом.



tg-me.com/golang_for_two/127
Create:
Last Update:

golang deep comparison for testing:

https://github.com/maxawww.tg-me.com/go-testdeep

import (
"testing"
"time"
)

func TestCreateRecord(t *testing.T) {
before := time.Now().Truncate(time.Second)
record, err := CreateRecord()

if err != nil {
t.Errorf("An error occurred: %s", err)
} else {
expected := Record{Name: "Bob", Age: 23}

if record.Id == 0 {
t.Error("Id probably not initialized")
}
if before.After(record.CreatedAt) ||
time.Now().Before(record.CreatedAt) {
t.Errorf("CreatedAt field not expected: %s", record.CreatedAt)
}
if record.Name != expected.Name {
t.Errorf("Name field differs, got=%s, expected=%s",
record.Name, expected.Name)
}
if record.Age != expected.Age {
t.Errorf("Age field differs, got=%s, expected=%s",
record.Age, expected.Age)
}
}
}

можно переписать в:
import (
"testing"
"time"

"github.com/maxawww.tg-me.com/go-testdeep/td"
)

func TestCreateRecord(t *testing.T) {
before := time.Now().Truncate(time.Second)
record, err := CreateRecord()

if td.CmpNoError(t, err) {
td.Cmp(t, record.Id, td.NotZero(), "Id initialized")
td.Cmp(t, record.Name, "Bob")
td.Cmp(t, record.Age, 23)
td.Cmp(t, record.CreatedAt, td.Between(before, time.Now()))
}
}


P.S. в проде не юзал но выглядит аккуратно, особенно когда происходит расхождение с ожидаемым результатом.

BY 🇺🇦 Go for two :)




Share with your friend now:
tg-me.com/golang_for_two/127

View MORE
Open in Telegram


🇺🇦 Go на двоих Telegram | DID YOU KNOW?

Date: |

Can I mute a Telegram group?

In recent times, Telegram has gained a lot of popularity because of the controversy over WhatsApp’s new privacy policy. In January 2021, Telegram was the most downloaded app worldwide and crossed 500 million monthly active users. And with so many active users on the app, people might get messages in bulk from a group or a channel that can be a little irritating. So to get rid of the same, you can mute groups, chats, and channels on Telegram just like WhatsApp. You can mute notifications for one hour, eight hours, or two days, or you can disable notifications forever.

Newly uncovered hack campaign in Telegram

The campaign, which security firm Check Point has named Rampant Kitten, comprises two main components, one for Windows and the other for Android. Rampant Kitten’s objective is to steal Telegram messages, passwords, and two-factor authentication codes sent by SMS and then also take screenshots and record sounds within earshot of an infected phone, the researchers said in a post published on Friday.

🇺🇦 Go на двоих from us


Telegram 🇺🇦 Go for two :)
FROM USA