(t *testing.T)
| 1065 | } |
| 1066 | |
| 1067 | func TestExitCodeForCommonFailures(t *testing.T) { |
| 1068 | tests := []struct { |
| 1069 | name string |
| 1070 | err error |
| 1071 | want int |
| 1072 | }{ |
| 1073 | { |
| 1074 | name: "generic", |
| 1075 | err: errors.New("unexpected local failure"), |
| 1076 | want: exitCodeGenericError, |
| 1077 | }, |
| 1078 | { |
| 1079 | name: "auth", |
| 1080 | err: authRequiredErrorf("no saved Dropbox credentials"), |
| 1081 | want: exitCodeAuthFailure, |
| 1082 | }, |
| 1083 | { |
| 1084 | name: "permission denied", |
| 1085 | err: dropboxauth.AccessAPIError{}, |
| 1086 | want: exitCodePermissionDenied, |
| 1087 | }, |
| 1088 | { |
| 1089 | name: "not found", |
| 1090 | err: files.GetMetadataAPIError{APIError: dropbox.APIError{ErrorSummary: "path/not_found/"}}, |
| 1091 | want: exitCodeNotFound, |
| 1092 | }, |
| 1093 | { |
| 1094 | name: "conflict", |
| 1095 | err: pathConflictErrorWithPath("/file", "path exists and is not a folder: /file"), |
| 1096 | want: exitCodeConflict, |
| 1097 | }, |
| 1098 | { |
| 1099 | name: "rate limited", |
| 1100 | err: dropboxauth.RateLimitAPIError{}, |
| 1101 | want: exitCodeRateLimited, |
| 1102 | }, |
| 1103 | { |
| 1104 | name: "validation", |
| 1105 | err: invalidArgumentsErrorWithDetails("missing path", argumentErrorDetails("path")), |
| 1106 | want: exitCodeValidationError, |
| 1107 | }, |
| 1108 | { |
| 1109 | name: "partial transfer", |
| 1110 | err: partialStdoutError(12), |
| 1111 | want: exitCodePartialTransfer, |
| 1112 | }, |
| 1113 | } |
| 1114 | |
| 1115 | for _, tt := range tests { |
| 1116 | t.Run(tt.name, func(t *testing.T) { |
| 1117 | if got := exitCodeForError(tt.err); got != tt.want { |
| 1118 | t.Fatalf("exitCodeForError(%v) = %d, want %d", tt.err, got, tt.want) |
| 1119 | } |
| 1120 | }) |
| 1121 | } |
| 1122 | } |
| 1123 | |
| 1124 | func TestParseOutputFormatInvalidValueIsValidationError(t *testing.T) { |
nothing calls this directly
no test coverage detected