diff --git a/.gitignore b/.gitignore index 62c8935..aa7ac80 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.idea/ \ No newline at end of file +.idea/ +coverage.out diff --git a/bot_test.go b/bot_test.go index c47d677..4f36362 100644 --- a/bot_test.go +++ b/bot_test.go @@ -64,7 +64,7 @@ func TestSendWithMessage(t *testing.T) { } } -func TestSendWithPhoto(t *testing.T) { +func TestSendWithNewPhoto(t *testing.T) { bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_API_TOKEN")) if err != nil { @@ -79,6 +79,112 @@ func TestSendWithPhoto(t *testing.T) { } } + + +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() + } +} + func ExampleNewBotAPI() { bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken") if err != nil {