Tests validate the expiry time validator.
(t *testing.T)
| 267 | |
| 268 | // Tests validate the expiry time validator. |
| 269 | func TestIsValidExpiry(t *testing.T) { |
| 270 | testCases := []struct { |
| 271 | // Input. |
| 272 | duration time.Duration |
| 273 | // Expected result. |
| 274 | err error |
| 275 | // Flag to indicate whether the test should pass. |
| 276 | shouldPass bool |
| 277 | }{ |
| 278 | {100 * time.Millisecond, errInvalidArgument("Expires cannot be lesser than 1 second."), false}, |
| 279 | {604801 * time.Second, errInvalidArgument("Expires cannot be greater than 7 days."), false}, |
| 280 | {0 * time.Second, errInvalidArgument("Expires cannot be lesser than 1 second."), false}, |
| 281 | {1 * time.Second, nil, true}, |
| 282 | {10000 * time.Second, nil, true}, |
| 283 | {999 * time.Second, nil, true}, |
| 284 | } |
| 285 | |
| 286 | for i, testCase := range testCases { |
| 287 | err := isValidExpiry(testCase.duration) |
| 288 | if err != nil && testCase.shouldPass { |
| 289 | t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err.Error()) |
| 290 | } |
| 291 | if err == nil && !testCase.shouldPass { |
| 292 | t.Errorf("Test %d: Expected to fail with <ERROR> \"%s\", but passed instead", i+1, testCase.err.Error()) |
| 293 | } |
| 294 | // Failed as expected, but does it fail for the expected reason. |
| 295 | if err != nil && !testCase.shouldPass { |
| 296 | if err.Error() != testCase.err.Error() { |
| 297 | t.Errorf("Test %d: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead", i+1, testCase.err.Error(), err.Error()) |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | // Tests validate the bucket name validator. |
| 304 | func TestIsValidBucketName(t *testing.T) { |
nothing calls this directly
no test coverage detected