(t *testing.T)
| 1028 | } |
| 1029 | |
| 1030 | func 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 | |
| 1067 | func TestExitCodeForCommonFailures(t *testing.T) { |
| 1068 | tests := []struct { |
nothing calls this directly
no test coverage detected