Test wrong bot token.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-10-04 22:09:10 +08:00
parent b903ef1afd
commit 541efa4e5b
2 changed files with 28 additions and 1 deletions

View File

@ -90,7 +90,7 @@ func (p Plugin) Exec() error {
message = p.Message(p.Repo, p.Build)
}
bot, err := tgbotapi.NewBotAPI("219364688:AAETlB6U1OZGnadM6-pLC1QUiXdeHlPUu1E")
bot, err := tgbotapi.NewBotAPI(p.Config.Token)
if err != nil {
log.Println(err.Error())

View File

@ -81,6 +81,33 @@ func TestSendMessage(t *testing.T) {
assert.Nil(t, err)
}
func TestBotError(t *testing.T) {
plugin := Plugin{
Repo: Repo{
Name: "go-hello",
Owner: "appleboy",
},
Build: Build{
Number: 101,
Status: "success",
Link: "https://github.com/appleboy/go-hello",
Author: "Bo-Yi Wu",
Branch: "master",
Message: "update travis by drone plugin",
Commit: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
},
Config: Config{
Token: "appleboy",
To: []string{os.Getenv("TELEGRAM_TO"), "中文ID", "1234567890"},
Message: []string{"Test Telegram Chat Bot From Travis or Local", " "},
},
}
err := plugin.Exec()
assert.NotNil(t, err)
}
func TestTrimElement(t *testing.T) {
var input, result []string