More various small code quality improvements.

bot-api-6.1
Syfaro 2018-03-26 12:39:07 -05:00
parent 1aef8c8c45
commit b728fa78fc
3 changed files with 17 additions and 14 deletions

View File

@ -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()
}

View File

@ -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))
}

View File

@ -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()
}
}