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,76 @@
|
||||
package peers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tg"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tgmock"
|
||||
)
|
||||
|
||||
type multiChat interface {
|
||||
Peer
|
||||
Creator() bool
|
||||
Left() bool
|
||||
NoForwards() bool
|
||||
CallActive() bool
|
||||
CallNotEmpty() bool
|
||||
ParticipantsCount() int
|
||||
AdminRights() (tg.ChatAdminRights, bool)
|
||||
DefaultBannedRights() (tg.ChatBannedRights, bool)
|
||||
|
||||
Leave(ctx context.Context) error
|
||||
SetTitle(ctx context.Context, title string) error
|
||||
SetDescription(ctx context.Context, about string) error
|
||||
|
||||
InviteLinks() InviteLinks
|
||||
ToBroadcast() (Broadcast, bool)
|
||||
IsBroadcast() bool
|
||||
ToSupergroup() (Supergroup, bool)
|
||||
IsSupergroup() bool
|
||||
|
||||
SetReactions(ctx context.Context, r ...tg.ReactionClass) error
|
||||
DisableReactions(ctx context.Context) error
|
||||
}
|
||||
|
||||
var _ = []multiChat{
|
||||
Chat{},
|
||||
Channel{},
|
||||
}
|
||||
|
||||
func TestReactions(t *testing.T) {
|
||||
a := require.New(t)
|
||||
ctx := context.Background()
|
||||
mock, m := testManager(t)
|
||||
|
||||
req := func(p Peer, r ...tg.ReactionClass) *tgmock.RequestBuilder {
|
||||
var reactions tg.ChatReactionsClass = &tg.ChatReactionsSome{Reactions: r}
|
||||
if len(r) == 0 {
|
||||
reactions = &tg.ChatReactionsNone{}
|
||||
}
|
||||
return mock.ExpectCall(&tg.MessagesSetChatAvailableReactionsRequest{
|
||||
Peer: p.InputPeer(),
|
||||
AvailableReactions: reactions,
|
||||
})
|
||||
}
|
||||
reactions := []tg.ReactionClass{
|
||||
&tg.ReactionEmoji{Emoticon: "👍"},
|
||||
&tg.ReactionEmoji{Emoticon: "A"},
|
||||
}
|
||||
for _, p := range []multiChat{
|
||||
m.Chat(getTestChat()),
|
||||
m.Channel(getTestChannel()),
|
||||
} {
|
||||
req(p, reactions...).ThenRPCErr(getTestError())
|
||||
a.Error(p.SetReactions(ctx, reactions...))
|
||||
req(p, reactions...).ThenResult(&tg.Updates{})
|
||||
a.NoError(p.SetReactions(ctx, reactions...))
|
||||
|
||||
req(p).ThenRPCErr(getTestError())
|
||||
a.Error(p.DisableReactions(ctx))
|
||||
req(p).ThenResult(&tg.Updates{})
|
||||
a.NoError(p.DisableReactions(ctx))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user