Browse Source

Merge pull request #35273 from chchliang/containerstate

add testcase IsValidStateString
Michael Crosby 7 years ago
parent
commit
05026b187b
1 changed files with 24 additions and 0 deletions
  1. 24 0
      container/state_test.go

+ 24 - 0
container/state_test.go

@@ -166,3 +166,27 @@ func TestStateTimeoutWait(t *testing.T) {
 		}
 	}
 }
+
+func TestIsValidStateString(t *testing.T) {
+	states := []struct {
+		state    string
+		expected bool
+	}{
+		{"paused", true},
+		{"restarting", true},
+		{"running", true},
+		{"dead", true},
+		{"start", false},
+		{"created", true},
+		{"exited", true},
+		{"removing", true},
+		{"stop", false},
+	}
+
+	for _, s := range states {
+		v := IsValidStateString(s.state)
+		if v != s.expected {
+			t.Fatalf("Expected %t, but got %t", s.expected, v)
+		}
+	}
+}