github.com/skf/moby@v1.13.1/container/container_unit_test.go (about) 1 package container 2 3 import ( 4 "testing" 5 6 "github.com/docker/docker/api/types/container" 7 "github.com/docker/docker/pkg/signal" 8 ) 9 10 func TestContainerStopSignal(t *testing.T) { 11 c := &Container{ 12 CommonContainer: CommonContainer{ 13 Config: &container.Config{}, 14 }, 15 } 16 17 def, err := signal.ParseSignal(signal.DefaultStopSignal) 18 if err != nil { 19 t.Fatal(err) 20 } 21 22 s := c.StopSignal() 23 if s != int(def) { 24 t.Fatalf("Expected %v, got %v", def, s) 25 } 26 27 c = &Container{ 28 CommonContainer: CommonContainer{ 29 Config: &container.Config{StopSignal: "SIGKILL"}, 30 }, 31 } 32 s = c.StopSignal() 33 if s != 9 { 34 t.Fatalf("Expected 9, got %v", s) 35 } 36 } 37 38 func TestContainerStopTimeout(t *testing.T) { 39 c := &Container{ 40 CommonContainer: CommonContainer{ 41 Config: &container.Config{}, 42 }, 43 } 44 45 s := c.StopTimeout() 46 if s != DefaultStopTimeout { 47 t.Fatalf("Expected %v, got %v", DefaultStopTimeout, s) 48 } 49 50 stopTimeout := 15 51 c = &Container{ 52 CommonContainer: CommonContainer{ 53 Config: &container.Config{StopTimeout: &stopTimeout}, 54 }, 55 } 56 s = c.StopSignal() 57 if s != 15 { 58 t.Fatalf("Expected 15, got %v", s) 59 } 60 }