Return possible states a heal operation (#4045)

This commit is contained in:
Krishnan Parthasarathi
2017-04-14 22:58:35 +05:30
committed by Harshavardhana
parent 5f065e2a96
commit ca64b86112
5 changed files with 109 additions and 15 deletions
+26
View File
@@ -1586,3 +1586,29 @@ func TestListHealUploadsHandler(t *testing.T) {
}
}
// Test for newHealResult helper function.
func TestNewHealResult(t *testing.T) {
testCases := []struct {
healedDisks int
offlineDisks int
state healState
}{
// 1. No disks healed, no disks offline.
{0, 0, healNone},
// 2. No disks healed, non-zero disks offline.
{0, 1, healNone},
// 3. Non-zero disks healed, no disks offline.
{1, 0, healOK},
// 4. Non-zero disks healed, non-zero disks offline.
{1, 1, healPartial},
}
for i, test := range testCases {
actual := newHealResult(test.healedDisks, test.offlineDisks)
if actual.State != test.state {
t.Errorf("Test %d: Expected %v but received %v", i+1,
test.state, actual.State)
}
}
}