all repos — telegram-bot-api @ 3a60d28d73265c48475c2cf9f99b0842a88f1090

Golang bindings for the Telegram Bot API

Tests for PinChatMessage and UnpinChatMessage methods
Lord-Protector savely@krasovsky.me
Sat, 05 Aug 2017 12:37:43 +0300
commit

3a60d28d73265c48475c2cf9f99b0842a88f1090

parent

b24a37443a9122cc263f3f82eaeb6b687d65db76

1 files changed, 46 insertions(+), 0 deletions(-)

jump to
M bot_test.gobot_test.go

@@ -609,3 +609,49 @@ t.Error(err)

t.Fail() } } + +func TestPinChatMessage(t *testing.T) { + bot, _ := getBot(t) + + msg := tgbotapi.NewMessage(ChatID, "A test message from the test library in telegram-bot-api") + msg.ParseMode = "markdown" + message, _ := bot.Send(msg) + + pinChatMessageConfig := tgbotapi.PinChatMessageConfig{ + ChatID: message.Chat.ID, + MessageID: message.MessageID, + DisableNotification: false, + } + _, err := bot.PinChatMessage(pinChatMessageConfig) + + if err != nil { + t.Error(err) + t.Fail() + } +} + +func TestUnpinChatMessage(t *testing.T) { + bot, _ := getBot(t) + + msg := tgbotapi.NewMessage(ChatID, "A test message from the test library in telegram-bot-api") + msg.ParseMode = "markdown" + message, _ := bot.Send(msg) + + // We need pin message to unpin something + pinChatMessageConfig := tgbotapi.PinChatMessageConfig{ + ChatID: message.Chat.ID, + MessageID: message.MessageID, + DisableNotification: false, + } + _, err := bot.PinChatMessage(pinChatMessageConfig) + + unpinChatMessageConfig := tgbotapi.UnpinChatMessageConfig{ + ChatID: message.Chat.ID, + } + _, err = bot.UnpinChatMessage(unpinChatMessageConfig) + + if err != nil { + t.Error(err) + t.Fail() + } +}