Skip to content

Commit 64abb76

Browse files
committed
test(mail): assert typed ExitError in TestValidateNoSignatureConflict
Use errors.As + *output.ExitError to assert exit code ExitValidation(2) and detail type "validation", consistent with mail_confirm_send_scope_test.go. Change-Type: ci-fix
1 parent dc674af commit 64abb76

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

shortcuts/mail/signature_compose_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,26 @@
44
package mail
55

66
import (
7+
"errors"
78
"testing"
9+
10+
"github.com/larksuite/cli/internal/output"
811
)
912

1013
func TestValidateNoSignatureConflictTypedError(t *testing.T) {
1114
err := validateNoSignatureConflict(true, "sig_123")
1215
if err == nil {
1316
t.Fatal("expected error, got nil")
1417
}
15-
// output.ErrValidation returns *output.ExitError (exit code 2).
16-
if err.Error() == "" {
17-
t.Fatalf("expected non-empty error message, got %T (%v)", err, err)
18+
var exitErr *output.ExitError
19+
if !errors.As(err, &exitErr) {
20+
t.Fatalf("expected *output.ExitError, got %T: %v", err, err)
21+
}
22+
if exitErr.Code != output.ExitValidation {
23+
t.Errorf("expected exit code %d (ExitValidation), got %d", output.ExitValidation, exitErr.Code)
24+
}
25+
if exitErr.Detail == nil || exitErr.Detail.Type != "validation" {
26+
t.Errorf("expected detail type validation, got %+v", exitErr.Detail)
1827
}
1928
}
2029

0 commit comments

Comments
 (0)