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,46 @@
|
||||
package peers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tg"
|
||||
)
|
||||
|
||||
func TestManager_applyChats(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
a := require.New(t)
|
||||
_, m := testManager(t)
|
||||
|
||||
chats := []tg.ChatClass{
|
||||
&tg.ChatEmpty{ID: 1},
|
||||
&tg.Chat{ID: 2},
|
||||
&tg.ChatForbidden{ID: 3},
|
||||
&tg.Channel{ID: 4, AccessHash: 14},
|
||||
&tg.ChannelForbidden{ID: 5, AccessHash: 15},
|
||||
}
|
||||
|
||||
// Ensure nil safety.
|
||||
a.NoError(m.applyChats(ctx, nil, nil, nil))
|
||||
a.NoError(m.applyChats(ctx, chats...))
|
||||
|
||||
_, ok, err := m.storage.Find(ctx, Key{ID: 2, Prefix: chatsPrefix})
|
||||
a.NoError(err)
|
||||
a.True(ok)
|
||||
|
||||
_, ok, err = m.storage.Find(ctx, Key{ID: 3, Prefix: chatsPrefix})
|
||||
a.NoError(err)
|
||||
a.True(ok)
|
||||
|
||||
v, ok, err := m.storage.Find(ctx, Key{ID: 4, Prefix: channelPrefix})
|
||||
a.NoError(err)
|
||||
a.True(ok)
|
||||
a.Equal(int64(14), v.AccessHash)
|
||||
|
||||
v, ok, err = m.storage.Find(ctx, Key{ID: 5, Prefix: channelPrefix})
|
||||
a.NoError(err)
|
||||
a.True(ok)
|
||||
a.Equal(int64(15), v.AccessHash)
|
||||
}
|
||||
Reference in New Issue
Block a user