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
57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
package inline
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tg"
|
|
)
|
|
|
|
func TestDocument(t *testing.T) {
|
|
ctx := context.Background()
|
|
builder, mock := testBuilder(t)
|
|
doc := &tg.InputDocument{ID: 10, AccessHash: 10, FileReference: []byte{10}}
|
|
|
|
mock.ExpectFunc(func(b bin.Encoder) {
|
|
v, ok := b.(*tg.MessagesSetInlineBotResultsRequest)
|
|
require.True(t, ok)
|
|
require.Equal(t, int64(10), v.QueryID)
|
|
|
|
for i := range v.Results {
|
|
r, ok := v.Results[i].(*tg.InputBotInlineResultDocument)
|
|
require.True(t, ok)
|
|
require.NotZero(t, r.ID)
|
|
require.Equal(t, doc, r.Document)
|
|
require.Equal(t, r.Title, r.Type)
|
|
require.Equal(t, r.Description, r.Title)
|
|
}
|
|
}).ThenTrue()
|
|
_, err := builder.Set(ctx,
|
|
Video(doc, MessageText("video")).Title(VideoType).
|
|
Description(VideoType),
|
|
File(doc, MessageText("file")).ID("10").Title(DocumentType).
|
|
Description(DocumentType),
|
|
Audio(doc, MessageText("audio")).ID("10").Title(AudioType).
|
|
Description(AudioType),
|
|
GIF(doc, MessageText("gif")).ID("10").Title(GIFType).
|
|
Description(GIFType),
|
|
MPEG4GIF(doc, MessageText("mpeg4gif")).ID("10").Title(MPEG4GIFType).
|
|
Description(MPEG4GIFType),
|
|
Voice(doc, MessageText("voice")).ID("10").Title(VoiceType).
|
|
Description(VoiceType),
|
|
Sticker(doc, MessageText("sticker")).ID("10").Title(StickerType).
|
|
Description(StickerType),
|
|
)
|
|
require.NoError(t, err)
|
|
|
|
mock.Expect().ThenRPCErr(testRPCError())
|
|
_, err = builder.Set(ctx,
|
|
Video(doc, MessageText("video")).Title(VideoType).
|
|
Description(VideoType),
|
|
)
|
|
require.Error(t, err)
|
|
}
|