Bootstrap copied BFF and local accounts with public Sendico contracts (#34)
This commit is contained in:
1 parent
67dc5b5b1e
commit
7062672a87
556 files changed
+42291
-777
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package merrors
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestWithThrottlePreservesClassificationAndDetails(t *testing.T) {
|
||||
base := Define("verificationLimited")
|
||||
err := Wrap(
|
||||
WithThrottle(base, " destination ", 45*time.Second, "request is temporarily limited"),
|
||||
"verification failed",
|
||||
)
|
||||
|
||||
if !errors.Is(err, base) {
|
||||
t.Fatalf("throttle error did not preserve classification: %v", err)
|
||||
}
|
||||
details, ok := ThrottleDetailsFrom(err)
|
||||
if !ok {
|
||||
t.Fatal("throttle details were not available through wrapping")
|
||||
}
|
||||
if details.ScopeKind != "destination" || details.RetryAfter != 45*time.Second {
|
||||
t.Fatalf("unexpected throttle details: %+v", details)
|
||||
}
|
||||
if got, want := err.Error(), "verificationLimited: request is temporarily limited: verification failed"; got != want {
|
||||
t.Fatalf("unexpected throttle error text: got=%q want=%q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestThrottleDetailsFromRejectsUnannotatedError(t *testing.T) {
|
||||
if details, ok := ThrottleDetailsFrom(ServiceUnavailable("dependency unavailable")); ok {
|
||||
t.Fatalf("unexpected throttle details: %+v", details)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user