add createdState and runningState status testcase
Signed-off-by: chchliang <chen.chuanliang@zte.com.cn>
This commit is contained in:
parent
ef9a4b3155
commit
4f0e6c4ef0
|
@ -78,3 +78,40 @@ func TestRestoredStateTransition(t *testing.T) {
|
|||
t.Fatal("expected stateTransitionError")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunningStateTransition(t *testing.T) {
|
||||
s := &runningState{c: &linuxContainer{}}
|
||||
valid := []containerState{
|
||||
&stoppedState{},
|
||||
&pausedState{},
|
||||
&runningState{},
|
||||
}
|
||||
for _, v := range valid {
|
||||
if err := s.transition(v); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
err := s.transition(&createdState{})
|
||||
if err == nil {
|
||||
t.Fatal("transition to created state should fail")
|
||||
}
|
||||
if !isStateTransitionError(err) {
|
||||
t.Fatal("expected stateTransitionError")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreatedStateTransition(t *testing.T) {
|
||||
s := &createdState{c: &linuxContainer{}}
|
||||
valid := []containerState{
|
||||
&stoppedState{},
|
||||
&pausedState{},
|
||||
&runningState{},
|
||||
&createdState{},
|
||||
}
|
||||
for _, v := range valid {
|
||||
if err := s.transition(v); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue