diff --git a/bot_test.go b/bot_test.go index 73f43d3..5986247 100644 --- a/bot_test.go +++ b/bot_test.go @@ -258,6 +258,113 @@ func TestSendWithLocation(t *testing.T) { } } +func TestSendWithNewVideo(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + msg := tgbotapi.NewVideoUpload(76918703, "tests/video.mp4") + msg.Duration = 10 + msg.Caption = "TEST" + + _, err = bot.Send(msg) + + if err != nil { + + t.Fail() + } +} + +func TestSendWithExistingVideo(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + msg := tgbotapi.NewVideoShare(76918703, "BAADAgADRgADhwGzCopBeKJ7rv9SAg") + msg.Duration = 10 + msg.Caption = "TEST" + + _, err = bot.Send(msg) + + if err != nil { + + t.Fail() + } +} + +func TestSendWithNewSticker(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + msg := tgbotapi.NewStickerUpload(76918703, "tests/image.jpg") + + _, err = bot.Send(msg) + + if err != nil { + + t.Fail() + } +} + +func TestSendWithExistingSticker(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + msg := tgbotapi.NewStickerShare(76918703, "BQADAgADUwADhwGzCmwtOypNFlrRAg") + + _, err = bot.Send(msg) + + if err != nil { + + t.Fail() + } +} + +func TestSendWithNewStickerAndKeyboardHide(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + msg := tgbotapi.NewStickerUpload(76918703, "tests/image.jpg") + msg.ReplyMarkup = tgbotapi.ReplyKeyboardHide{true, false} + _, err = bot.Send(msg) + + if err != nil { + + t.Fail() + } +} + +func TestSendWithExistingStickerAndKeyboardHide(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + msg := tgbotapi.NewStickerShare(76918703, "BQADAgADUwADhwGzCmwtOypNFlrRAg") + msg.ReplyMarkup = tgbotapi.ReplyKeyboardHide{true, false} + + _, err = bot.Send(msg) + + if err != nil { + + t.Fail() + } +} + func TestGetFile(t *testing.T) { bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) diff --git a/tests/video.mp4 b/tests/video.mp4 new file mode 100644 index 0000000..a203d0c Binary files /dev/null and b/tests/video.mp4 differ diff --git a/types_test.go b/types_test.go new file mode 100644 index 0000000..1e0036d --- /dev/null +++ b/types_test.go @@ -0,0 +1,74 @@ +package tgbotapi_test + +import ( + "github.com/zhulik/telegram-bot-api" + "testing" + "time" +) + +func TestUserStringWith(t *testing.T) { + user := tgbotapi.User{0, "Test", "Test", ""} + + if user.String() != "Test Test" { + t.Fail() + } +} + +func TestUserStringWithUserName(t *testing.T) { + user := tgbotapi.User{0, "Test", "Test", "@test"} + + if user.String() != "@test" { + t.Fail() + } +} + +func TestMessageIsGroup(t *testing.T) { + from := tgbotapi.User{ID: 0} + chat := tgbotapi.Chat{ID: 10} + message := tgbotapi.Message{From: from, Chat: chat} + + if message.IsGroup() != true { + t.Fail() + } +} + +func TestMessageTime(t *testing.T) { + message := tgbotapi.Message{Date: 0} + + date := time.Unix(0, 0) + if message.Time() != date { + t.Fail() + } +} + +func TestChatIsPrivate(t *testing.T) { + chat := tgbotapi.Chat{ID: 10, Type: "private"} + + if chat.IsPrivate() != true { + t.Fail() + } +} + +func TestChatIsGroup(t *testing.T) { + chat := tgbotapi.Chat{ID: 10, Type: "group"} + + if chat.IsGroup() != true { + t.Fail() + } +} + +func TestChatIsChannel(t *testing.T) { + chat := tgbotapi.Chat{ID: 10, Type: "channel"} + + if chat.IsChannel() != true { + t.Fail() + } +} + +func TestFileLink(t *testing.T) { + file := tgbotapi.File{FilePath: "test/test.txt"} + + if file.Link("token") != "https://api.telegram.org/file/bottoken/test/test.txt" { + t.Fail() + } +} \ No newline at end of file