MCPcopy
hub / github.com/opencontainers/runc / testTransitions

Function testTransitions

libcontainer/state_linux_test.go:26–51  ·  view source on GitHub ↗
(t *testing.T, initialState containerState, valid []containerState)

Source from the content-addressed store, hash-verified

24}
25
26func testTransitions(t *testing.T, initialState containerState, valid []containerState) {
27 validMap := map[reflect.Type]any{}
28 for _, validState := range valid {
29 validMap[reflect.TypeOf(validState)] = nil
30 t.Run(validState.status().String(), func(t *testing.T) {
31 if err := initialState.transition(validState); err != nil {
32 t.Fatal(err)
33 }
34 })
35 }
36 for state := range states {
37 if _, ok := validMap[reflect.TypeOf(state)]; ok {
38 continue
39 }
40 t.Run(state.status().String(), func(t *testing.T) {
41 err := initialState.transition(state)
42 if err == nil {
43 t.Fatal("transition should fail")
44 }
45 var stErr *stateTransitionError
46 if !errors.As(err, &stErr) {
47 t.Fatal("expected stateTransitionError")
48 }
49 })
50 }
51}
52
53func TestStoppedStateTransition(t *testing.T) {
54 testTransitions(

Callers 5

Calls 4

RunMethod · 0.65
statusMethod · 0.65
transitionMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…