move gotd fork into repo. (#111)
- 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
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/crypto"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/session/tdesktop"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/dcs"
|
||||
)
|
||||
|
||||
func TestTDesktopSession(t *testing.T) {
|
||||
key := crypto.Key{}
|
||||
keyID := key.ID()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
account tdesktop.Account
|
||||
want *Data
|
||||
wantErr bool
|
||||
}{
|
||||
{"OK", tdesktop.Account{
|
||||
Authorization: tdesktop.MTPAuthorization{
|
||||
MainDC: 2,
|
||||
Keys: map[int]crypto.Key{
|
||||
2: key,
|
||||
},
|
||||
},
|
||||
}, &Data{
|
||||
DC: 2,
|
||||
Config: Config{
|
||||
ThisDC: 2,
|
||||
},
|
||||
Addr: findDCAddr(dcs.Prod().Options, 2),
|
||||
AuthKey: key[:],
|
||||
AuthKeyID: keyID[:],
|
||||
}, false},
|
||||
{"UnknownDC", tdesktop.Account{
|
||||
Authorization: tdesktop.MTPAuthorization{
|
||||
MainDC: 200,
|
||||
Keys: map[int]crypto.Key{
|
||||
200: key,
|
||||
},
|
||||
},
|
||||
}, nil, true},
|
||||
{"NoKey", tdesktop.Account{}, nil, true},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
a := require.New(t)
|
||||
got, err := TDesktopSession(tt.account)
|
||||
if tt.wantErr {
|
||||
a.Nil(got)
|
||||
a.Error(err)
|
||||
} else {
|
||||
a.Equal(tt.want, got)
|
||||
a.NoError(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user