27 lines
849 B
Go
27 lines
849 B
Go
package merrors
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestPaymentExecutionNotAcceptedPreservesClassificationAndCause(t *testing.T) {
|
|
cause := ServiceUnavailable("orchestrator unavailable")
|
|
err := PaymentExecutionNotAcceptedWrap(cause, "execution was rejected")
|
|
|
|
if !errors.Is(err, ErrFailedPrecondition) ||
|
|
!errors.Is(err, ErrPaymentExecutionNotAccepted) ||
|
|
!errors.Is(err, cause) {
|
|
t.Fatalf("PaymentExecutionNotAcceptedWrap() classification = %v", err)
|
|
}
|
|
reason, ok := Reason(err)
|
|
if !ok || reason != ReasonPaymentExecutionNotAccepted {
|
|
t.Fatalf("PaymentExecutionNotAcceptedWrap() reason = %q, %t", reason, ok)
|
|
}
|
|
restored, ok := FromReason(reason, err.Error())
|
|
if !ok || !errors.Is(restored, ErrPaymentExecutionNotAccepted) ||
|
|
!errors.Is(restored, ErrFailedPrecondition) {
|
|
t.Fatalf("FromReason() = %v, %t", restored, ok)
|
|
}
|
|
}
|