Merge pull request #375 from Eivel/develop

Handle error in NewWebhook and NewWebhookWithCert
This commit is contained in:
Syfaro 2021-03-10 22:00:07 -05:00 committed by GitHub
commit 53d566ba56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 12 deletions

View file

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