MCPcopy Create free account
hub / github.com/AbelChe/evil_minio / TestToAdminAPIErrCode

Function TestToAdminAPIErrCode

cmd/admin-handlers_test.go:299–328  ·  view source on GitHub ↗

TestToAdminAPIErrCode - test for toAdminAPIErrCode helper function.

(t *testing.T)

Source from the content-addressed store, hash-verified

297
298// TestToAdminAPIErrCode - test for toAdminAPIErrCode helper function.
299func 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
330func TestExtractHealInitParams(t *testing.T) {
331 mkParams := func(clientToken string, forceStart, forceStop bool) url.Values {

Callers

nothing calls this directly

Calls 2

toAPIErrorCodeFunction · 0.85
toAdminAPIErrCodeFunction · 0.85

Tested by

no test coverage detected