Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
38 lines
871 B
Go
38 lines
871 B
Go
package processing
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestClientErrorRecognizesRateLimit(t *testing.T) {
|
|
msg, ok := ClientError(ErrRateLimited)
|
|
if !ok {
|
|
t.Fatal("expected ErrRateLimited to be a client error")
|
|
}
|
|
if msg != ErrRateLimited.Error() {
|
|
t.Fatalf("msg=%q", msg)
|
|
}
|
|
if !errors.Is(ErrRateLimited, ErrRateLimited) {
|
|
t.Fatal("sentinel identity broken")
|
|
}
|
|
}
|
|
|
|
func TestClientErrorRecognizesWrappedTooManyProducts(t *testing.T) {
|
|
err := fmt.Errorf("%w (max %d)", ErrTooManyProducts, 50)
|
|
msg, ok := ClientError(err)
|
|
if !ok {
|
|
t.Fatal("expected wrapped ErrTooManyProducts")
|
|
}
|
|
if msg != "too many products (max 50)" {
|
|
t.Fatalf("msg=%q", msg)
|
|
}
|
|
}
|
|
|
|
func TestClientErrorRejectsOpaqueErrors(t *testing.T) {
|
|
if _, ok := ClientError(errors.New("pq: connection refused")); ok {
|
|
t.Fatal("opaque DB error must not be treated as client-safe")
|
|
}
|
|
}
|