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,78 @@
|
||||
package message
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tg"
|
||||
)
|
||||
|
||||
func TestPhoto(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
sender, mock := testSender(t)
|
||||
loc := &tg.InputPhoto{
|
||||
ID: 10,
|
||||
}
|
||||
|
||||
expectSendMedia(t, &tg.InputMediaPhoto{ID: loc}, mock)
|
||||
expectSendMedia(t, &tg.InputMediaPhoto{
|
||||
ID: loc,
|
||||
TTLSeconds: 10,
|
||||
}, mock)
|
||||
|
||||
_, err := sender.Self().Photo(ctx, loc)
|
||||
require.NoError(t, err)
|
||||
_, err = sender.Self().Media(ctx, Photo(loc).TTL(10*time.Second))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestPhotoExternal(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
sender, mock := testSender(t)
|
||||
|
||||
expectSendMedia(t, &tg.InputMediaPhotoExternal{URL: "https://google.com"}, mock)
|
||||
expectSendMedia(t, &tg.InputMediaPhotoExternal{
|
||||
URL: "https://github.com",
|
||||
TTLSeconds: 10,
|
||||
}, mock)
|
||||
|
||||
_, err := sender.Self().PhotoExternal(ctx, "https://google.com")
|
||||
require.NoError(t, err)
|
||||
_, err = sender.Self().Media(ctx, PhotoExternal("https://github.com").TTL(10*time.Second))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestUploadedPhoto(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
sender, mock := testSender(t)
|
||||
file := &tg.InputFile{
|
||||
ID: 10,
|
||||
}
|
||||
loc := &tg.InputDocumentFileLocation{
|
||||
ID: 10,
|
||||
}
|
||||
|
||||
expectSendMedia(t, &tg.InputMediaUploadedPhoto{
|
||||
File: file,
|
||||
}, mock)
|
||||
expectSendMedia(t, &tg.InputMediaUploadedPhoto{
|
||||
File: file,
|
||||
TTLSeconds: 10,
|
||||
}, mock)
|
||||
expectSendMedia(t, &tg.InputMediaUploadedPhoto{
|
||||
File: file,
|
||||
Stickers: []tg.InputDocumentClass{&tg.InputDocument{
|
||||
ID: loc.GetID(),
|
||||
}},
|
||||
}, mock)
|
||||
|
||||
_, err := sender.Self().UploadedPhoto(ctx, file)
|
||||
require.NoError(t, err)
|
||||
_, err = sender.Self().Media(ctx, UploadedPhoto(file).TTL(10*time.Second))
|
||||
require.NoError(t, err)
|
||||
_, err = sender.Self().Media(ctx, UploadedPhoto(file).Stickers(loc))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
Reference in New Issue
Block a user