container_unit_test.go 639 B

123456789101112131415161718192021222324252627282930313233343536
  1. package container
  2. import (
  3. "testing"
  4. "github.com/docker/docker/pkg/signal"
  5. "github.com/docker/engine-api/types/container"
  6. )
  7. func TestContainerStopSignal(t *testing.T) {
  8. c := &Container{
  9. CommonContainer: CommonContainer{
  10. Config: &container.Config{},
  11. },
  12. }
  13. def, err := signal.ParseSignal(signal.DefaultStopSignal)
  14. if err != nil {
  15. t.Fatal(err)
  16. }
  17. s := c.StopSignal()
  18. if s != int(def) {
  19. t.Fatalf("Expected %v, got %v", def, s)
  20. }
  21. c = &Container{
  22. CommonContainer: CommonContainer{
  23. Config: &container.Config{StopSignal: "SIGKILL"},
  24. },
  25. }
  26. s = c.StopSignal()
  27. if s != 9 {
  28. t.Fatalf("Expected 9, got %v", s)
  29. }
  30. }