all repos — telegram-bot-api @ b8425b053e0ac70e917076ef036661da382bd7c3

Golang bindings for the Telegram Bot API

Add missing tests
Henner kein.regen@wolke7.net
Sat, 07 Oct 2017 18:06:20 +0200
commit

b8425b053e0ac70e917076ef036661da382bd7c3

parent

c697a95948b08fd61419986d493601d14f3b3744

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

jump to
M types_test.gotypes_test.go

@@ -91,10 +91,27 @@ t.Fail()

} } +func TestCommandWithAtWithBotName(t *testing.T) { + message := tgbotapi.Message{Text: "/command@testbot"} + message.Entities = &[]tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 16}} + + if message.CommandWithAt() != "command@testbot" { + t.Fail() + } +} + func TestMessageCommandArgumentsWithArguments(t *testing.T) { message := tgbotapi.Message{Text: "/command with arguments"} message.Entities = &[]tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 8}} if message.CommandArguments() != "with arguments" { + t.Fail() + } +} + +func TestMessageCommandArgumentsWithMalformedArguments(t *testing.T) { + message := tgbotapi.Message{Text: "/command-without argument space"} + message.Entities = &[]tgbotapi.MessageEntity{{Type: "bot_command", Offset: 0, Length: 8}} + if message.CommandArguments() != "without argument space" { t.Fail() } }