2016-04-14 21:00:45 +02:00
|
|
|
package tgbotapi_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-telegram-bot-api/telegram-bot-api"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewInlineQueryResultArticle(t *testing.T) {
|
2016-06-02 22:41:55 +02:00
|
|
|
result := tgbotapi.NewInlineQueryResultArticle("id", "title", "message")
|
2016-04-14 21:00:45 +02:00
|
|
|
|
|
|
|
if result.Type != "article" ||
|
|
|
|
result.ID != "id" ||
|
|
|
|
result.Title != "title" ||
|
2016-06-02 22:41:55 +02:00
|
|
|
result.InputMessageContent.(tgbotapi.InputTextMessageContent).Text != "message" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewInlineQueryResultArticleMarkdown(t *testing.T) {
|
|
|
|
result := tgbotapi.NewInlineQueryResultArticleMarkdown("id", "title", "*message*")
|
|
|
|
|
|
|
|
if result.Type != "article" ||
|
|
|
|
result.ID != "id" ||
|
|
|
|
result.Title != "title" ||
|
|
|
|
result.InputMessageContent.(tgbotapi.InputTextMessageContent).Text != "*message*" ||
|
2016-06-02 21:42:05 +02:00
|
|
|
result.InputMessageContent.(tgbotapi.InputTextMessageContent).ParseMode != "Markdown" {
|
2016-04-14 21:00:45 +02:00
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-02 22:41:55 +02:00
|
|
|
func TestNewInlineQueryResultArticleHTML(t *testing.T) {
|
|
|
|
result := tgbotapi.NewInlineQueryResultArticleHTML("id", "title", "<b>message</b>")
|
|
|
|
|
|
|
|
if result.Type != "article" ||
|
|
|
|
result.ID != "id" ||
|
|
|
|
result.Title != "title" ||
|
|
|
|
result.InputMessageContent.(tgbotapi.InputTextMessageContent).Text != "<b>message</b>" ||
|
|
|
|
result.InputMessageContent.(tgbotapi.InputTextMessageContent).ParseMode != "HTML" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-14 21:00:45 +02:00
|
|
|
func TestNewInlineQueryResultGIF(t *testing.T) {
|
|
|
|
result := tgbotapi.NewInlineQueryResultGIF("id", "google.com")
|
|
|
|
|
|
|
|
if result.Type != "gif" ||
|
|
|
|
result.ID != "id" ||
|
|
|
|
result.URL != "google.com" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewInlineQueryResultMPEG4GIF(t *testing.T) {
|
|
|
|
result := tgbotapi.NewInlineQueryResultMPEG4GIF("id", "google.com")
|
|
|
|
|
|
|
|
if result.Type != "mpeg4_gif" ||
|
|
|
|
result.ID != "id" ||
|
|
|
|
result.URL != "google.com" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewInlineQueryResultPhoto(t *testing.T) {
|
|
|
|
result := tgbotapi.NewInlineQueryResultPhoto("id", "google.com")
|
|
|
|
|
|
|
|
if result.Type != "photo" ||
|
|
|
|
result.ID != "id" ||
|
|
|
|
result.URL != "google.com" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-26 20:44:48 +02:00
|
|
|
func TestNewInlineQueryResultPhotoWithThumb(t *testing.T) {
|
|
|
|
result := tgbotapi.NewInlineQueryResultPhotoWithThumb("id", "google.com", "thumb.com")
|
|
|
|
|
|
|
|
if result.Type != "photo" ||
|
|
|
|
result.ID != "id" ||
|
|
|
|
result.URL != "google.com" ||
|
|
|
|
result.ThumbURL != "thumb.com" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-14 21:00:45 +02:00
|
|
|
func TestNewInlineQueryResultVideo(t *testing.T) {
|
|
|
|
result := tgbotapi.NewInlineQueryResultVideo("id", "google.com")
|
|
|
|
|
|
|
|
if result.Type != "video" ||
|
|
|
|
result.ID != "id" ||
|
|
|
|
result.URL != "google.com" {
|
2016-04-14 21:04:35 +02:00
|
|
|
t.Fail()
|
2016-04-14 21:00:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewInlineQueryResultAudio(t *testing.T) {
|
|
|
|
result := tgbotapi.NewInlineQueryResultAudio("id", "google.com", "title")
|
|
|
|
|
|
|
|
if result.Type != "audio" ||
|
|
|
|
result.ID != "id" ||
|
|
|
|
result.URL != "google.com" ||
|
|
|
|
result.Title != "title" {
|
2016-04-14 21:04:35 +02:00
|
|
|
t.Fail()
|
2016-04-14 21:00:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewInlineQueryResultVoice(t *testing.T) {
|
|
|
|
result := tgbotapi.NewInlineQueryResultVoice("id", "google.com", "title")
|
|
|
|
|
|
|
|
if result.Type != "voice" ||
|
|
|
|
result.ID != "id" ||
|
|
|
|
result.URL != "google.com" ||
|
|
|
|
result.Title != "title" {
|
2016-04-14 21:04:35 +02:00
|
|
|
t.Fail()
|
2016-04-14 21:00:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewInlineQueryResultDocument(t *testing.T) {
|
|
|
|
result := tgbotapi.NewInlineQueryResultDocument("id", "google.com", "title", "mime/type")
|
|
|
|
|
|
|
|
if result.Type != "document" ||
|
|
|
|
result.ID != "id" ||
|
|
|
|
result.URL != "google.com" ||
|
|
|
|
result.Title != "title" ||
|
|
|
|
result.MimeType != "mime/type" {
|
2016-04-14 21:04:35 +02:00
|
|
|
t.Fail()
|
2016-04-14 21:00:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewInlineQueryResultLocation(t *testing.T) {
|
|
|
|
result := tgbotapi.NewInlineQueryResultLocation("id", "name", 40, 50)
|
|
|
|
|
|
|
|
if result.Type != "location" ||
|
|
|
|
result.ID != "id" ||
|
|
|
|
result.Title != "name" ||
|
|
|
|
result.Latitude != 40 ||
|
|
|
|
result.Longitude != 50 {
|
2016-04-14 21:04:35 +02:00
|
|
|
t.Fail()
|
2016-04-14 21:00:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewEditMessageText(t *testing.T) {
|
|
|
|
edit := tgbotapi.NewEditMessageText(ChatID, ReplyToMessageID, "new text")
|
|
|
|
|
|
|
|
if edit.Text != "new text" ||
|
|
|
|
edit.BaseEdit.ChatID != ChatID ||
|
|
|
|
edit.BaseEdit.MessageID != ReplyToMessageID {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewEditMessageCaption(t *testing.T) {
|
2018-10-15 11:11:02 +02:00
|
|
|
edit := tgbotapi.NewEditMessageCaption(ChatID, ReplyToMessageID, "new caption")
|
2016-04-14 21:00:45 +02:00
|
|
|
|
|
|
|
if edit.Caption != "new caption" ||
|
|
|
|
edit.BaseEdit.ChatID != ChatID ||
|
|
|
|
edit.BaseEdit.MessageID != ReplyToMessageID {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewEditMessageReplyMarkup(t *testing.T) {
|
|
|
|
markup := tgbotapi.InlineKeyboardMarkup{
|
|
|
|
InlineKeyboard: [][]tgbotapi.InlineKeyboardButton{
|
|
|
|
[]tgbotapi.InlineKeyboardButton{
|
|
|
|
tgbotapi.InlineKeyboardButton{Text: "test"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
edit := tgbotapi.NewEditMessageReplyMarkup(ChatID, ReplyToMessageID, markup)
|
|
|
|
|
|
|
|
if edit.ReplyMarkup.InlineKeyboard[0][0].Text != "test" ||
|
|
|
|
edit.BaseEdit.ChatID != ChatID ||
|
|
|
|
edit.BaseEdit.MessageID != ReplyToMessageID {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|