Add unit tests for server-main.go (#2802)

This commit is contained in:
Krishnan Parthasarathi
2016-09-28 23:49:07 +05:30
committed by Harshavardhana
parent 1edd74dda2
commit 428629f577
2 changed files with 303 additions and 68 deletions

View File

@@ -22,74 +22,6 @@ import (
"testing"
)
// Collection of disks verbatim used for tests.
var disks = []string{
"/mnt/backend1",
"/mnt/backend2",
"/mnt/backend3",
"/mnt/backend4",
"/mnt/backend5",
"/mnt/backend6",
"/mnt/backend7",
"/mnt/backend8",
"/mnt/backend9",
"/mnt/backend10",
"/mnt/backend11",
"/mnt/backend12",
"/mnt/backend13",
"/mnt/backend14",
"/mnt/backend15",
"/mnt/backend16",
}
// Tests all the expected input disks for function checkSufficientDisks.
func TestCheckSufficientDisks(t *testing.T) {
// List of test cases fo sufficient disk verification.
testCases := []struct {
disks []string
expectedErr error
}{
// Even number of disks '6'.
{
disks[0:6],
nil,
},
// Even number of disks '12'.
{
disks[0:12],
nil,
},
// Even number of disks '16'.
{
disks[0:16],
nil,
},
// Larger than maximum number of disks > 16.
{
append(disks[0:16], "/mnt/unsupported"),
errXLMaxDisks,
},
// Lesser than minimum number of disks < 6.
{
disks[0:3],
errXLMinDisks,
},
// Odd number of disks, not divisible by '2'.
{
append(disks[0:10], disks[11]),
errXLNumDisks,
},
}
// Validates different variations of input disks.
for i, testCase := range testCases {
if checkSufficientDisks(testCase.disks) != testCase.expectedErr {
t.Errorf("Test %d expected to pass for disks %s", i+1, testCase.disks)
}
}
}
// TestStorageInfo - tests storage info.
func TestStorageInfo(t *testing.T) {
objLayer, fsDirs, err := prepareXL()