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
51 lines
1.1 KiB
Go
51 lines
1.1 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 TestPhoto(t *testing.T) {
|
|
ctx := context.Background()
|
|
builder, mock := testBuilder(t)
|
|
photo := &tg.InputPhoto{
|
|
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.InputBotInlineResultPhoto)
|
|
require.True(t, ok)
|
|
require.NotZero(t, r.ID)
|
|
require.Equal(t, photo, r.Photo)
|
|
}
|
|
}).ThenTrue()
|
|
_, err := builder.Set(ctx,
|
|
Photo(photo, MessageText("photo")),
|
|
Photo(photo, MessageText("photo")).ID("10"),
|
|
)
|
|
require.NoError(t, err)
|
|
|
|
mock.Expect().ThenRPCErr(testRPCError())
|
|
_, err = builder.Set(ctx,
|
|
Photo(photo, MessageGeo(&tg.InputGeoPoint{
|
|
Lat: 10,
|
|
Long: 42,
|
|
AccuracyRadius: 1337,
|
|
})),
|
|
Photo(photo, MessageGame()).ID("10"),
|
|
)
|
|
require.Error(t, err)
|
|
}
|