35 lines
852 B
Go
35 lines
852 B
Go
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)
|
|
}
|
|
}
|
|
}
|
|
}
|