fix tests, linter errors and fmt
zhuharev kirill@zhuharev.ru
Thu, 09 Nov 2017 21:51:50 +0300
3 files changed,
27 insertions(+),
10 deletions(-)
M
bot.go
→
bot.go
@@ -748,6 +748,7 @@
return bot.MakeRequest("restrictChatMember", v) } +// PromoteChatMember add admin rights to user func (bot *BotAPI) PromoteChatMember(config PromoteChatMemberConfig) (APIResponse, error) { v := url.Values{}@@ -864,6 +865,9 @@ v.Add("chat_id", config.SuperGroupUsername)
} resp, err := bot.MakeRequest("exportChatInviteLink", v) + if err != nil { + return "", err + } var inviteLink string err = json.Unmarshal(resp.Result, &inviteLink)@@ -871,7 +875,7 @@
return inviteLink, err } -// Pin message in supergroup +// PinChatMessage pin message in supergroup func (bot *BotAPI) PinChatMessage(config PinChatMessageConfig) (APIResponse, error) { v, err := config.values() if err != nil {@@ -883,7 +887,7 @@
return bot.MakeRequest(config.method(), v) } -// Unpin message in supergroup +// UnpinChatMessage unpin message in supergroup func (bot *BotAPI) UnpinChatMessage(config UnpinChatMessageConfig) (APIResponse, error) { v, err := config.values() if err != nil {
M
bot_test.go
→
bot_test.go
@@ -619,8 +619,8 @@ msg.ParseMode = "markdown"
message, _ := bot.Send(msg) pinChatMessageConfig := tgbotapi.PinChatMessageConfig{ - ChatID: message.Chat.ID, - MessageID: message.MessageID, + ChatID: message.Chat.ID, + MessageID: message.MessageID, DisableNotification: false, } _, err := bot.PinChatMessage(pinChatMessageConfig)@@ -640,14 +640,14 @@ message, _ := bot.Send(msg)
// We need pin message to unpin something pinChatMessageConfig := tgbotapi.PinChatMessageConfig{ - ChatID: message.Chat.ID, - MessageID: message.MessageID, + ChatID: message.Chat.ID, + MessageID: message.MessageID, DisableNotification: false, } _, err := bot.PinChatMessage(pinChatMessageConfig) unpinChatMessageConfig := tgbotapi.UnpinChatMessageConfig{ - ChatID: message.Chat.ID, + ChatID: message.Chat.ID, } _, err = bot.UnpinChatMessage(unpinChatMessageConfig)@@ -655,4 +655,4 @@ if err != nil {
t.Error(err) t.Fail() } -}+}
M
types_test.go
→
types_test.go
@@ -8,7 +8,14 @@ "github.com/go-telegram-bot-api/telegram-bot-api"
) func TestUserStringWith(t *testing.T) { - user := tgbotapi.User{0, "Test", "Test", "", "en", false} + user := tgbotapi.User{ + ID: 0, + FirstName: "Test", + LastName: "Test", + UserName: "", + LanguageCode: "en", + IsBot: false, + } if user.String() != "Test Test" { t.Fail()@@ -16,7 +23,13 @@ }
} func TestUserStringWithUserName(t *testing.T) { - user := tgbotapi.User{0, "Test", "Test", "@test", "en"} + user := tgbotapi.User{ + ID: 0, + FirstName: "Test", + LastName: "Test", + UserName: "@test", + LanguageCode: "en", + } if user.String() != "@test" { t.Fail()