Merge pull request #375 from Eivel/develop
Handle error in NewWebhook and NewWebhookWithCert
This commit is contained in:
commit
53d566ba56
3 changed files with 69 additions and 12 deletions
36
bot_test.go
36
bot_test.go
|
@ -550,8 +550,13 @@ func TestSetWebhookWithCert(t *testing.T) {
|
|||
|
||||
bot.Request(DeleteWebhookConfig{})
|
||||
|
||||
wh := NewWebhookWithCert("https://example.com/tgbotapi-test/"+bot.Token, "tests/cert.pem")
|
||||
_, err := bot.Request(wh)
|
||||
wh, err := NewWebhookWithCert("https://example.com/tgbotapi-test/"+bot.Token, "tests/cert.pem")
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = bot.Request(wh)
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -572,8 +577,14 @@ func TestSetWebhookWithoutCert(t *testing.T) {
|
|||
|
||||
bot.Request(DeleteWebhookConfig{})
|
||||
|
||||
wh := NewWebhook("https://example.com/tgbotapi-test/" + bot.Token)
|
||||
_, err := bot.Request(wh)
|
||||
wh, err := NewWebhook("https://example.com/tgbotapi-test/" + bot.Token)
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
_, err = bot.Request(wh)
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -704,7 +715,14 @@ func ExampleNewWebhook() {
|
|||
|
||||
log.Printf("Authorized on account %s", bot.Self.UserName)
|
||||
|
||||
_, err = bot.Request(NewWebhookWithCert("https://www.google.com:8443/"+bot.Token, "cert.pem"))
|
||||
wh, err := NewWebhookWithCert("https://www.google.com:8443/"+bot.Token, "cert.pem")
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
_, err = bot.Request(wh)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -737,7 +755,13 @@ func ExampleWebhookHandler() {
|
|||
|
||||
log.Printf("Authorized on account %s", bot.Self.UserName)
|
||||
|
||||
_, err = bot.Request(NewWebhookWithCert("https://www.google.com:8443/"+bot.Token, "cert.pem"))
|
||||
wh, err := NewWebhookWithCert("https://www.google.com:8443/"+bot.Token, "cert.pem")
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
_, err = bot.Request(wh)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue