From b728fa78fc94abdd39b0f24bf71dc1d245385059 Mon Sep 17 00:00:00 2001 From: Syfaro Date: Mon, 26 Mar 2018 12:39:07 -0500 Subject: [PATCH] More various small code quality improvements. --- bot_test.go | 9 ++++++--- configs.go | 10 +++++----- types_test.go | 12 ++++++------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/bot_test.go b/bot_test.go index 1727396..0ca1bb2 100644 --- a/bot_test.go +++ b/bot_test.go @@ -682,14 +682,17 @@ func TestUnpinChatMessage(t *testing.T) { MessageID: message.MessageID, DisableNotification: false, } - _, err := bot.Request(pinChatMessageConfig) + + if _, err := bot.Request(pinChatMessageConfig); err != nil { + t.Error(err) + t.Fail() + } unpinChatMessageConfig := tgbotapi.UnpinChatMessageConfig{ ChatID: message.Chat.ID, } - _, err = bot.Request(unpinChatMessageConfig) - if err != nil { + if _, err := bot.Request(unpinChatMessageConfig); err != nil { t.Error(err) t.Fail() } diff --git a/configs.go b/configs.go index e8c4514..0f9bd10 100644 --- a/configs.go +++ b/configs.go @@ -1269,19 +1269,19 @@ func (config InvoiceConfig) values() (url.Values, error) { if config.PhotoHeight != 0 { v.Add("photo_height", strconv.Itoa(config.PhotoHeight)) } - if config.NeedName != false { + if config.NeedName { v.Add("need_name", strconv.FormatBool(config.NeedName)) } - if config.NeedPhoneNumber != false { + if config.NeedPhoneNumber { v.Add("need_phone_number", strconv.FormatBool(config.NeedPhoneNumber)) } - if config.NeedEmail != false { + if config.NeedEmail { v.Add("need_email", strconv.FormatBool(config.NeedEmail)) } - if config.NeedShippingAddress != false { + if config.NeedShippingAddress { v.Add("need_shipping_address", strconv.FormatBool(config.NeedShippingAddress)) } - if config.IsFlexible != false { + if config.IsFlexible { v.Add("is_flexible", strconv.FormatBool(config.IsFlexible)) } diff --git a/types_test.go b/types_test.go index bb7bb64..8a67c8e 100644 --- a/types_test.go +++ b/types_test.go @@ -49,7 +49,7 @@ func TestMessageIsCommandWithCommand(t *testing.T) { message := tgbotapi.Message{Text: "/command"} message.Entities = &[]tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 8}} - if message.IsCommand() != true { + if !message.IsCommand() { t.Fail() } } @@ -57,7 +57,7 @@ func TestMessageIsCommandWithCommand(t *testing.T) { func TestIsCommandWithText(t *testing.T) { message := tgbotapi.Message{Text: "some text"} - if message.IsCommand() != false { + if message.IsCommand() { t.Fail() } } @@ -65,7 +65,7 @@ func TestIsCommandWithText(t *testing.T) { func TestIsCommandWithEmptyText(t *testing.T) { message := tgbotapi.Message{Text: ""} - if message.IsCommand() != false { + if message.IsCommand() { t.Fail() } } @@ -162,7 +162,7 @@ func TestMessageEntityParseURLBad(t *testing.T) { func TestChatIsPrivate(t *testing.T) { chat := tgbotapi.Chat{ID: 10, Type: "private"} - if chat.IsPrivate() != true { + if !chat.IsPrivate() { t.Fail() } } @@ -170,7 +170,7 @@ func TestChatIsPrivate(t *testing.T) { func TestChatIsGroup(t *testing.T) { chat := tgbotapi.Chat{ID: 10, Type: "group"} - if chat.IsGroup() != true { + if !chat.IsGroup() { t.Fail() } } @@ -178,7 +178,7 @@ func TestChatIsGroup(t *testing.T) { func TestChatIsChannel(t *testing.T) { chat := tgbotapi.Chat{ID: 10, Type: "channel"} - if chat.IsChannel() != true { + if !chat.IsChannel() { t.Fail() } }