all repos — telegram-bot-api @ e7b9f16e73b8f9d5ba62cc4b0736d493bf72e1d1

Golang bindings for the Telegram Bot API

helpers_test.go (view raw)

  1package tgbotapi_test
  2
  3import (
  4	"github.com/go-telegram-bot-api/telegram-bot-api"
  5	"testing"
  6)
  7
  8func TestNewInlineQueryResultArticle(t *testing.T) {
  9	result := tgbotapi.NewInlineQueryResultArticle("id", "title", "message")
 10
 11	if result.Type != "article" ||
 12		result.ID != "id" ||
 13		result.Title != "title" ||
 14		result.InputMessageContent.(tgbotapi.InputTextMessageContent).Text != "message" {
 15		t.Fail()
 16	}
 17}
 18
 19func TestNewInlineQueryResultGIF(t *testing.T) {
 20	result := tgbotapi.NewInlineQueryResultGIF("id", "google.com")
 21
 22	if result.Type != "gif" ||
 23		result.ID != "id" ||
 24		result.URL != "google.com" {
 25		t.Fail()
 26	}
 27}
 28
 29func TestNewInlineQueryResultMPEG4GIF(t *testing.T) {
 30	result := tgbotapi.NewInlineQueryResultMPEG4GIF("id", "google.com")
 31
 32	if result.Type != "mpeg4_gif" ||
 33		result.ID != "id" ||
 34		result.URL != "google.com" {
 35		t.Fail()
 36	}
 37}
 38
 39func TestNewInlineQueryResultPhoto(t *testing.T) {
 40	result := tgbotapi.NewInlineQueryResultPhoto("id", "google.com")
 41
 42	if result.Type != "photo" ||
 43		result.ID != "id" ||
 44		result.URL != "google.com" {
 45		t.Fail()
 46	}
 47}
 48
 49func TestNewInlineQueryResultVideo(t *testing.T) {
 50	result := tgbotapi.NewInlineQueryResultVideo("id", "google.com")
 51
 52	if result.Type != "video" ||
 53		result.ID != "id" ||
 54		result.URL != "google.com" {
 55	}
 56}
 57
 58func TestNewInlineQueryResultAudio(t *testing.T) {
 59	result := tgbotapi.NewInlineQueryResultAudio("id", "google.com", "title")
 60
 61	if result.Type != "audio" ||
 62		result.ID != "id" ||
 63		result.URL != "google.com" ||
 64		result.Title != "title" {
 65	}
 66}
 67
 68func TestNewInlineQueryResultVoice(t *testing.T) {
 69	result := tgbotapi.NewInlineQueryResultVoice("id", "google.com", "title")
 70
 71	if result.Type != "voice" ||
 72		result.ID != "id" ||
 73		result.URL != "google.com" ||
 74		result.Title != "title" {
 75	}
 76}
 77
 78func TestNewInlineQueryResultDocument(t *testing.T) {
 79	result := tgbotapi.NewInlineQueryResultDocument("id", "google.com", "title", "mime/type")
 80
 81	if result.Type != "document" ||
 82		result.ID != "id" ||
 83		result.URL != "google.com" ||
 84		result.Title != "title" ||
 85		result.MimeType != "mime/type" {
 86	}
 87}
 88
 89func TestNewInlineQueryResultLocation(t *testing.T) {
 90	result := tgbotapi.NewInlineQueryResultLocation("id", "name", 40, 50)
 91
 92	if result.Type != "location" ||
 93		result.ID != "id" ||
 94		result.Title != "name" ||
 95		result.Latitude != 40 ||
 96		result.Longitude != 50 {
 97	}
 98}
 99
100func TestNewEditMessageText(t *testing.T) {
101	edit := tgbotapi.NewEditMessageText(ChatID, ReplyToMessageID, "new text")
102
103	if edit.Text != "new text" ||
104		edit.BaseEdit.ChatID != ChatID ||
105		edit.BaseEdit.MessageID != ReplyToMessageID {
106		t.Fail()
107	}
108}
109
110func TestNewEditMessageCaption(t *testing.T) {
111	edit := tgbotapi.NewEditMessageCaption(ChatID, ReplyToMessageID, "new caption")
112
113	if edit.Caption != "new caption" ||
114		edit.BaseEdit.ChatID != ChatID ||
115		edit.BaseEdit.MessageID != ReplyToMessageID {
116		t.Fail()
117	}
118}
119
120func TestNewEditMessageReplyMarkup(t *testing.T) {
121	markup := tgbotapi.InlineKeyboardMarkup{
122		InlineKeyboard: [][]tgbotapi.InlineKeyboardButton{
123			[]tgbotapi.InlineKeyboardButton{
124				tgbotapi.InlineKeyboardButton{Text: "test"},
125			},
126		},
127	}
128
129	edit := tgbotapi.NewEditMessageReplyMarkup(ChatID, ReplyToMessageID, markup)
130
131	if edit.ReplyMarkup.InlineKeyboard[0][0].Text != "test" ||
132		edit.BaseEdit.ChatID != ChatID ||
133		edit.BaseEdit.MessageID != ReplyToMessageID {
134		t.Fail()
135	}
136
137}