7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
40 lines
833 B
Go
40 lines
833 B
Go
package tdsync
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/go-faster/errors"
|
|
"github.com/stretchr/testify/require"
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap/zapcore"
|
|
"go.uber.org/zap/zaptest"
|
|
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/clock"
|
|
)
|
|
|
|
func TestLogGroup(t *testing.T) {
|
|
hook := func(e zapcore.Entry) error {
|
|
require.Contains(t, e.LoggerName, "group")
|
|
return nil
|
|
}
|
|
log := zaptest.NewLogger(t, zaptest.WrapOptions(zap.Hooks(hook)))
|
|
grp := NewLogGroup(context.Background(), log.Named("group"))
|
|
grp.SetClock(clock.System)
|
|
|
|
grp.Go("test-task", func(groupCtx context.Context) error {
|
|
<-groupCtx.Done()
|
|
return groupCtx.Err()
|
|
})
|
|
|
|
grp.Go("test-task2", func(groupCtx context.Context) error {
|
|
<-groupCtx.Done()
|
|
return nil
|
|
})
|
|
|
|
grp.Cancel()
|
|
if err := grp.Wait(); !errors.Is(err, context.Canceled) {
|
|
t.Error(err)
|
|
}
|
|
}
|