TestToAdminAPIErrCode - test for toAdminAPIErrCode helper function.
(t *testing.T)
| 297 | |
| 298 | // TestToAdminAPIErrCode - test for toAdminAPIErrCode helper function. |
| 299 | func TestToAdminAPIErrCode(t *testing.T) { |
| 300 | testCases := []struct { |
| 301 | err error |
| 302 | expectedAPIErr APIErrorCode |
| 303 | }{ |
| 304 | // 1. Server not in quorum. |
| 305 | { |
| 306 | err: errErasureWriteQuorum, |
| 307 | expectedAPIErr: ErrAdminConfigNoQuorum, |
| 308 | }, |
| 309 | // 2. No error. |
| 310 | { |
| 311 | err: nil, |
| 312 | expectedAPIErr: ErrNone, |
| 313 | }, |
| 314 | // 3. Non-admin API specific error. |
| 315 | { |
| 316 | err: errDiskNotFound, |
| 317 | expectedAPIErr: toAPIErrorCode(GlobalContext, errDiskNotFound), |
| 318 | }, |
| 319 | } |
| 320 | |
| 321 | for i, test := range testCases { |
| 322 | actualErr := toAdminAPIErrCode(GlobalContext, test.err) |
| 323 | if actualErr != test.expectedAPIErr { |
| 324 | t.Errorf("Test %d: Expected %v but received %v", |
| 325 | i+1, test.expectedAPIErr, actualErr) |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | func TestExtractHealInitParams(t *testing.T) { |
| 331 | mkParams := func(clientToken string, forceStart, forceStop bool) url.Values { |
nothing calls this directly
no test coverage detected