MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestExitCodeForStableJSONErrorCodes

Function TestExitCodeForStableJSONErrorCodes

cmd/output_test.go:1030–1065  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1028}
1029
1030func TestExitCodeForStableJSONErrorCodes(t *testing.T) {
1031 tests := []struct {
1032 code string
1033 want int
1034 }{
1035 {jsonErrorCodeAppKeyRequired, exitCodeAuthFailure},
1036 {jsonErrorCodeAuthExchangeFailed, exitCodeAuthFailure},
1037 {jsonErrorCodeAuthRefreshFailed, exitCodeAuthFailure},
1038 {jsonErrorCodeAuthRequired, exitCodeAuthFailure},
1039 {jsonErrorCodeCommandFailed, exitCodeGenericError},
1040 {jsonErrorCodeDropboxAPIError, exitCodeGenericError},
1041 {jsonErrorCodeEnvTokenStillActive, exitCodeAuthFailure},
1042 {jsonErrorCodeInvalidArguments, exitCodeValidationError},
1043 {jsonErrorCodeNotFound, exitCodeNotFound},
1044 {jsonErrorCodePartialTransfer, exitCodePartialTransfer},
1045 {jsonErrorCodePathConflict, exitCodeConflict},
1046 {jsonErrorCodePermissionDenied, exitCodePermissionDenied},
1047 {jsonErrorCodeRateLimited, exitCodeRateLimited},
1048 {jsonErrorCodeStructuredOutputUnsupported, exitCodeValidationError},
1049 {jsonErrorCodeUnknownCommand, exitCodeValidationError},
1050 {jsonErrorCodeUnknownFlag, exitCodeValidationError},
1051 }
1052
1053 if got := exitCodeForError(nil); got != exitCodeSuccess {
1054 t.Fatalf("exitCodeForError(nil) = %d, want %d", got, exitCodeSuccess)
1055 }
1056
1057 for _, tt := range tests {
1058 t.Run(tt.code, func(t *testing.T) {
1059 err := newCodedError(tt.code, errors.New(tt.code))
1060 if got := exitCodeForError(err); got != tt.want {
1061 t.Fatalf("exitCodeForError(%s) = %d, want %d", tt.code, got, tt.want)
1062 }
1063 })
1064 }
1065}
1066
1067func TestExitCodeForCommonFailures(t *testing.T) {
1068 tests := []struct {

Callers

nothing calls this directly

Calls 2

exitCodeForErrorFunction · 0.85
newCodedErrorFunction · 0.85

Tested by

no test coverage detected