inital commit
This commit is contained in:
34
errors_test.go
Normal file
34
errors_test.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package fa
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSystemMessageError_IsErrSystemMessage(t *testing.T) {
|
||||
err := &SystemMessageError{Title: "Something", Body: "broke"}
|
||||
if !errors.Is(err, ErrSystemMessage) {
|
||||
t.Fatalf("errors.Is(SystemMessageError, ErrSystemMessage) = false; want true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTPError_Format(t *testing.T) {
|
||||
e := &HTTPError{StatusCode: 503, URL: "https://example/"}
|
||||
if got := e.Error(); got != "fa: http 503 for https://example/" {
|
||||
t.Fatalf("HTTPError.Error() = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSentinelsAreDistinct(t *testing.T) {
|
||||
sentinels := []error{
|
||||
ErrNotFound, ErrUnauthorized, ErrCloudflareChallenge,
|
||||
ErrRateLimited, ErrSystemMessage, ErrParse,
|
||||
}
|
||||
for i, a := range sentinels {
|
||||
for j, b := range sentinels {
|
||||
if i != j && errors.Is(a, b) {
|
||||
t.Errorf("sentinel %v wrongly matches %v", a, b)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user