mirror of https://github.com/tucnak/telebot
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
567 B
Go
19 lines
567 B
Go
4 years ago
|
package telebot
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestExtractOk(t *testing.T) {
|
||
|
data := []byte(`{"ok":true,"result":{"foo":"bar"}}`)
|
||
|
assert.NoError(t, extractOk(data))
|
||
|
|
||
|
data = []byte(`{"ok":false,"error_code":429,"description":"Too Many Requests: retry after 8","parameters":{"retry_after":8}}`)
|
||
|
assert.Error(t, extractOk(data))
|
||
|
|
||
|
data = []byte(`{"ok":false,"error_code":400,"description":"Bad Request: reply message not found"}`) // Also check the old format
|
||
|
assert.EqualError(t, extractOk(data), ErrToReplyNotFound.Error())
|
||
|
}
|