tests: Add test for diskCount. (#2717)

Fixes #2312
This commit is contained in:
Harshavardhana
2016-09-16 13:44:52 -07:00
committed by GitHub
parent b89a1cd482
commit 9216981262
2 changed files with 27 additions and 2 deletions

View File

@@ -24,6 +24,31 @@ import (
"time"
)
// Tests caclculating disk count.
func TestDiskCount(t *testing.T) {
testCases := []struct {
disks []StorageAPI
diskCount int
}{
// Test case - 1
{
disks: []StorageAPI{&posix{}, &posix{}, &posix{}, &posix{}},
diskCount: 4,
},
// Test case - 2
{
disks: []StorageAPI{nil, &posix{}, &posix{}, &posix{}},
diskCount: 3,
},
}
for i, testCase := range testCases {
cdiskCount := diskCount(testCase.disks)
if cdiskCount != testCase.diskCount {
t.Errorf("Test %d: Expected %d, got %d", i+1, testCase.diskCount, cdiskCount)
}
}
}
// Test for reduceErrs, reduceErr reduces collection
// of errors into a single maximal error with in the list.
func TestReduceErrs(t *testing.T) {