From ada852aa701e1ba34fd29589401b114309a2f74f Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Tue, 28 Jul 2015 15:36:29 +0800 Subject: [PATCH] Merge daemon_unit_test.go to daemon_test.go daemon_test.go supposted to be unit test for daemon, so don't see reason why we need another daemon_unit_test.go. Signed-off-by: Qiang Huang --- daemon/daemon_test.go | 33 ++++++++++++++++++++++++++++++++ daemon/daemon_unit_test.go | 39 -------------------------------------- 2 files changed, 33 insertions(+), 39 deletions(-) delete mode 100644 daemon/daemon_unit_test.go diff --git a/daemon/daemon_test.go b/daemon/daemon_test.go index 5e0233da79..82cb3cfe41 100644 --- a/daemon/daemon_test.go +++ b/daemon/daemon_test.go @@ -11,6 +11,7 @@ import ( "github.com/docker/docker/pkg/graphdb" "github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/truncindex" + "github.com/docker/docker/runconfig" "github.com/docker/docker/volume" "github.com/docker/docker/volume/drivers" "github.com/docker/docker/volume/local" @@ -514,3 +515,35 @@ func initDaemonForVolumesTest(tmp string) (*Daemon, error) { return daemon, nil } + +func TestParseSecurityOpt(t *testing.T) { + container := &Container{} + config := &runconfig.HostConfig{} + + // test apparmor + config.SecurityOpt = []string{"apparmor:test_profile"} + if err := parseSecurityOpt(container, config); err != nil { + t.Fatalf("Unexpected parseSecurityOpt error: %v", err) + } + if container.AppArmorProfile != "test_profile" { + t.Fatalf("Unexpected AppArmorProfile, expected: \"test_profile\", got %q", container.AppArmorProfile) + } + + // test valid label + config.SecurityOpt = []string{"label:user:USER"} + if err := parseSecurityOpt(container, config); err != nil { + t.Fatalf("Unexpected parseSecurityOpt error: %v", err) + } + + // test invalid label + config.SecurityOpt = []string{"label"} + if err := parseSecurityOpt(container, config); err == nil { + t.Fatal("Expected parseSecurityOpt error, got nil") + } + + // test invalid opt + config.SecurityOpt = []string{"test"} + if err := parseSecurityOpt(container, config); err == nil { + t.Fatal("Expected parseSecurityOpt error, got nil") + } +} diff --git a/daemon/daemon_unit_test.go b/daemon/daemon_unit_test.go deleted file mode 100644 index fbc3302aaa..0000000000 --- a/daemon/daemon_unit_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package daemon - -import ( - "testing" - - "github.com/docker/docker/runconfig" -) - -func TestParseSecurityOpt(t *testing.T) { - container := &Container{} - config := &runconfig.HostConfig{} - - // test apparmor - config.SecurityOpt = []string{"apparmor:test_profile"} - if err := parseSecurityOpt(container, config); err != nil { - t.Fatalf("Unexpected parseSecurityOpt error: %v", err) - } - if container.AppArmorProfile != "test_profile" { - t.Fatalf("Unexpected AppArmorProfile, expected: \"test_profile\", got %q", container.AppArmorProfile) - } - - // test valid label - config.SecurityOpt = []string{"label:user:USER"} - if err := parseSecurityOpt(container, config); err != nil { - t.Fatalf("Unexpected parseSecurityOpt error: %v", err) - } - - // test invalid label - config.SecurityOpt = []string{"label"} - if err := parseSecurityOpt(container, config); err == nil { - t.Fatal("Expected parseSecurityOpt error, got nil") - } - - // test invalid opt - config.SecurityOpt = []string{"test"} - if err := parseSecurityOpt(container, config); err == nil { - t.Fatal("Expected parseSecurityOpt error, got nil") - } -}