Tests improved

bot-api-6.1
Gleb Sinyavsky 2015-11-20 19:43:56 +03:00
parent d0711736ec
commit e16094f76a
2 changed files with 109 additions and 2 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
.idea/
.idea/
coverage.out

View File

@ -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 {