瀏覽代碼

add e2e tests to check no profile usages

Signed-off-by: Guillaume Lours <[email protected]>
Guillaume Lours 2 年之前
父節點
當前提交
6fbef29619
共有 1 個文件被更改,包括 50 次插入0 次删除
  1. 50 0
      pkg/e2e/profiles_test.go

+ 50 - 0
pkg/e2e/profiles_test.go

@@ -57,3 +57,53 @@ func TestExplicitProfileUsage(t *testing.T) {
 		assert.Assert(t, !strings.Contains(res.Combined(), projectName), res.Combined())
 	})
 }
+
+func TestNoProfileUsage(t *testing.T) {
+	c := NewParallelCLI(t)
+	const projectName = "compose-e2e-no-profiles"
+
+	t.Run("compose up without profile", func(t *testing.T) {
+		res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml",
+			"-p", projectName, "up", "-d")
+		res.Assert(t, icmd.Expected{ExitCode: 0})
+		res = c.RunDockerComposeCmd(t, "-p", projectName, "ps")
+		res.Assert(t, icmd.Expected{Out: "main"})
+		assert.Assert(t, !strings.Contains(res.Combined(), "profiled-service"))
+	})
+
+	t.Run("compose stop without profile", func(t *testing.T) {
+		res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml",
+			"-p", projectName, "stop")
+		res.Assert(t, icmd.Expected{ExitCode: 0})
+		res = c.RunDockerComposeCmd(t, "-p", projectName, "ps", "--status", "running")
+		assert.Assert(t, !strings.Contains(res.Combined(), "profiled-service"))
+		assert.Assert(t, !strings.Contains(res.Combined(), "main"))
+	})
+
+	t.Run("compose start without profile", func(t *testing.T) {
+		res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml",
+			"-p", projectName, "start")
+		res.Assert(t, icmd.Expected{ExitCode: 0})
+		res = c.RunDockerComposeCmd(t, "-p", projectName, "ps", "--status", "running")
+		res.Assert(t, icmd.Expected{Out: "main"})
+		assert.Assert(t, !strings.Contains(res.Combined(), "profiled-service"))
+	})
+
+	t.Run("compose restart without profile", func(t *testing.T) {
+		res := c.RunDockerComposeCmd(t, "-f", "./fixtures/profiles/compose.yaml",
+			"-p", projectName, "restart")
+		res.Assert(t, icmd.Expected{ExitCode: 0})
+		res = c.RunDockerComposeCmd(t, "-p", projectName, "ps", "--status", "running")
+		res.Assert(t, icmd.Expected{Out: "main"})
+		assert.Assert(t, !strings.Contains(res.Combined(), "profiled-service"))
+	})
+
+	t.Run("down", func(t *testing.T) {
+		_ = c.RunDockerComposeCmd(t, "--project-name", projectName, "down")
+	})
+
+	t.Run("check containers after down", func(t *testing.T) {
+		res := c.RunDockerCmd(t, "ps", "--all")
+		assert.Assert(t, !strings.Contains(res.Combined(), projectName), res.Combined())
+	})
+}