mirror of
https://github.com/minio/minio.git
synced 2025-11-09 13:39:46 -05:00
fix: Better printing of XL config init error (#5284)
This commit is contained in:
committed by
Nitish Tiwari
parent
e3d841ffd1
commit
2244adff07
@@ -18,6 +18,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
@@ -312,3 +313,38 @@ func TestToS3ETag(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test contains
|
||||
func TestContains(t *testing.T) {
|
||||
|
||||
testErr := errors.New("test err")
|
||||
|
||||
testCases := []struct {
|
||||
slice interface{}
|
||||
elem interface{}
|
||||
found bool
|
||||
}{
|
||||
{nil, nil, false},
|
||||
{"1", "1", false},
|
||||
{nil, "1", false},
|
||||
{[]string{"1"}, nil, false},
|
||||
{[]string{}, "1", false},
|
||||
{[]string{"1"}, "1", true},
|
||||
{[]string{"2"}, "1", false},
|
||||
{[]string{"1", "2"}, "1", true},
|
||||
{[]string{"2", "1"}, "1", true},
|
||||
{[]string{"2", "1", "3"}, "1", true},
|
||||
{[]int{1, 2, 3}, "1", false},
|
||||
{[]int{1, 2, 3}, 2, true},
|
||||
{[]int{1, 2, 3, 4, 5, 6}, 7, false},
|
||||
{[]error{errors.New("new err")}, testErr, false},
|
||||
{[]error{errors.New("new err"), testErr}, testErr, true},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
found := contains(testCase.slice, testCase.elem)
|
||||
if found != testCase.found {
|
||||
t.Fatalf("Test %v: expected: %v, got: %v", i+1, testCase.found, found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user