Switch to new vendor directory layout
Fixes #113 Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
This commit is contained in:
parent
bc6adb7e4d
commit
d5742209d3
806 changed files with 2 additions and 7 deletions
79
vendor/github.com/opencontainers/runc/libcontainer/state_linux_test.go
generated
vendored
Normal file
79
vendor/github.com/opencontainers/runc/libcontainer/state_linux_test.go
generated
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
// +build linux
|
||||
|
||||
package libcontainer
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestStateStatus(t *testing.T) {
|
||||
states := map[containerState]Status{
|
||||
&stoppedState{}: Destroyed,
|
||||
&runningState{}: Running,
|
||||
&restoredState{}: Running,
|
||||
&pausedState{}: Paused,
|
||||
}
|
||||
for s, status := range states {
|
||||
if s.status() != status {
|
||||
t.Fatalf("state returned %s but expected %s", s.status(), status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func isStateTransitionError(err error) bool {
|
||||
_, ok := err.(*stateTransitionError)
|
||||
return ok
|
||||
}
|
||||
|
||||
func TestStoppedStateTransition(t *testing.T) {
|
||||
s := &stoppedState{c: &linuxContainer{}}
|
||||
valid := []containerState{
|
||||
&stoppedState{},
|
||||
&runningState{},
|
||||
&restoredState{},
|
||||
}
|
||||
for _, v := range valid {
|
||||
if err := s.transition(v); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
err := s.transition(&pausedState{})
|
||||
if err == nil {
|
||||
t.Fatal("transition to paused state should fail")
|
||||
}
|
||||
if !isStateTransitionError(err) {
|
||||
t.Fatal("expected stateTransitionError")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPausedStateTransition(t *testing.T) {
|
||||
s := &pausedState{c: &linuxContainer{}}
|
||||
valid := []containerState{
|
||||
&pausedState{},
|
||||
&runningState{},
|
||||
&stoppedState{},
|
||||
}
|
||||
for _, v := range valid {
|
||||
if err := s.transition(v); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRestoredStateTransition(t *testing.T) {
|
||||
s := &restoredState{c: &linuxContainer{}}
|
||||
valid := []containerState{
|
||||
&stoppedState{},
|
||||
&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")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue