Tests improved
Gleb Sinyavsky zhulik.gleb@gmail.com
Fri, 20 Nov 2015 19:43:56 +0300
2 files changed,
109 insertions(+),
2 deletions(-)
M
bot_test.go
→
bot_test.go
@@ -64,7 +64,7 @@ t.Fail()
} } -func TestSendWithPhoto(t *testing.T) { +func TestSendWithNewPhoto(t *testing.T) { bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) if err != nil {@@ -74,6 +74,112 @@
msg := tgbotapi.NewPhotoUpload(76918703, "tests/image.jpg") _, err = bot.Send(msg) + if err != nil { + t.Fail() + } +} + + + +func TestSendWithExistingPhoto(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + msg := tgbotapi.NewPhotoShare(76918703, "AgADAgADxKcxG4cBswqt13DnHOgbmBxDhCoABC0h01_AL4SKe20BAAEC") + _, err = bot.Send(msg) + + if err != nil { + t.Fail() + } +} + +func TestSendWithNewDocument(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + msg := tgbotapi.NewDocumentUpload(76918703, "tests/image.jpg") + _, err = bot.Send(msg) + + if err != nil { + t.Fail() + } +} + +func TestSendWithExistingDocument(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + msg := tgbotapi.NewDocumentShare(76918703, "BQADAgADBwADhwGzCjWgiUU4T8VNAg") + _, err = bot.Send(msg) + + if err != nil { + t.Fail() + } +} + +func TestGetFile(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + file := tgbotapi.FileConfig{"BQADAgADBwADhwGzCjWgiUU4T8VNAg"} + + _, err = bot.GetFile(file) + + if err != nil { + t.Fail() + } +} + +func TestSendChatConfig(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + err = bot.SendChatAction(tgbotapi.NewChatAction(76918703, tgbotapi.ChatTyping)) + + if err != nil { + t.Fail() + } +} + +func TestGetUserProfilePhotos(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + _, err = bot.GetUserProfilePhotos(tgbotapi.NewUserProfilePhotos(76918703)) + if err != nil { + t.Fail() + } +} + +func TestUpdatesChan(t *testing.T) { + bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) + + if err != nil { + t.Fail() + } + + var ucfg tgbotapi.UpdateConfig = tgbotapi.NewUpdate(0) + ucfg.Timeout = 60 + err = bot.UpdatesChan(ucfg) + if err != nil { t.Fail() }