github.com/ruphin/docker@v1.10.1/container/container_unit_test.go (about)

     1  package container
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/docker/docker/pkg/signal"
     7  	"github.com/docker/engine-api/types/container"
     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  }