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
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package e2etest
|
|
|
|
import (
|
|
"io"
|
|
"sync"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"go.uber.org/zap"
|
|
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/dcs"
|
|
)
|
|
|
|
// Suite is struct which contains external E2E test parameters.
|
|
type Suite struct {
|
|
TB require.TestingT
|
|
appID int
|
|
appHash string
|
|
dc int
|
|
logger *zap.Logger
|
|
|
|
rand io.Reader
|
|
// already used phone numbers
|
|
used map[string]struct{}
|
|
usedMux sync.Mutex
|
|
}
|
|
|
|
// NewSuite creates new Suite.
|
|
func NewSuite(tb require.TestingT, config TestOptions) *Suite {
|
|
config.setDefaults()
|
|
return &Suite{
|
|
TB: tb,
|
|
appID: config.AppID,
|
|
appHash: config.AppHash,
|
|
dc: config.DC,
|
|
logger: config.Logger,
|
|
rand: config.Random,
|
|
used: map[string]struct{}{},
|
|
}
|
|
}
|
|
|
|
// Client creates new *telegram.Client using this suite.
|
|
func (s *Suite) Client(logger *zap.Logger, handler telegram.UpdateHandler) *telegram.Client {
|
|
return telegram.NewClient(s.appID, s.appHash, telegram.Options{
|
|
DC: s.dc,
|
|
DCList: dcs.Test(),
|
|
Logger: logger,
|
|
UpdateHandler: handler,
|
|
})
|
|
}
|