From 3a60d28d73265c48475c2cf9f99b0842a88f1090 Mon Sep 17 00:00:00 2001 From: Lord-Protector Date: Sat, 5 Aug 2017 12:37:43 +0300 Subject: [PATCH] Tests for PinChatMessage and UnpinChatMessage methods --- bot_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/bot_test.go b/bot_test.go index d7cec08..0e45a38 100644 --- a/bot_test.go +++ b/bot_test.go @@ -609,3 +609,49 @@ func TestDeleteMessage(t *testing.T) { 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() + } +} \ No newline at end of file