-
-
Notifications
You must be signed in to change notification settings - Fork 126
/
suite.go
50 lines (43 loc) · 1.06 KB
/
suite.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package e2etest
import (
"io"
"sync"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"github.com/gotd/td/telegram"
"github.com/gotd/td/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,
})
}