Files
sxchnge/backend/pkg/merrors/aml_test.go
T

22 lines
740 B
Go

package merrors
import (
"errors"
"testing"
)
func TestAMLSourceIdempotencyConflictReasonRoundTrip(t *testing.T) {
err := AMLSourceIdempotencyConflict("key is bound to another source mutation")
if !errors.Is(err, ErrDataConflict) || !errors.Is(err, ErrAMLSourceIdempotencyConflict) {
t.Fatalf("AML source idempotency conflict classification mismatch: %v", err)
}
reason, ok := Reason(err)
if !ok || reason != ReasonAMLSourceIdempotencyConflict {
t.Fatalf("AML source idempotency reason mismatch: reason=%q ok=%t", reason, ok)
}
restored, ok := FromReason(reason, err.Error())
if !ok || !errors.Is(restored, ErrAMLSourceIdempotencyConflict) {
t.Fatalf("AML source idempotency reason did not round trip: %v", restored)
}
}