(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func TestConfigFromEnv(t *testing.T) { |
| 26 | c := NewParallelCLI(t) |
| 27 | defer c.cleanupWithDown(t, "configs") |
| 28 | |
| 29 | t.Run("config from file", func(t *testing.T) { |
| 30 | res := icmd.RunCmd(c.NewDockerComposeCmd(t, "-f", "./fixtures/configs/compose.yaml", "run", "from_file")) |
| 31 | res.Assert(t, icmd.Expected{Out: "This is my config file"}) |
| 32 | }) |
| 33 | |
| 34 | t.Run("config from env", func(t *testing.T) { |
| 35 | res := icmd.RunCmd(c.NewDockerComposeCmd(t, "-f", "./fixtures/configs/compose.yaml", "run", "from_env"), |
| 36 | func(cmd *icmd.Cmd) { |
| 37 | cmd.Env = append(cmd.Env, "CONFIG=config") |
| 38 | }) |
| 39 | res.Assert(t, icmd.Expected{Out: "config"}) |
| 40 | }) |
| 41 | |
| 42 | t.Run("config inlined", func(t *testing.T) { |
| 43 | res := icmd.RunCmd(c.NewDockerComposeCmd(t, "-f", "./fixtures/configs/compose.yaml", "run", "inlined"), |
| 44 | func(cmd *icmd.Cmd) { |
| 45 | cmd.Env = append(cmd.Env, "CONFIG=config") |
| 46 | }) |
| 47 | res.Assert(t, icmd.Expected{Out: "This is my config"}) |
| 48 | }) |
| 49 | |
| 50 | t.Run("custom target", func(t *testing.T) { |
| 51 | res := icmd.RunCmd(c.NewDockerComposeCmd(t, "-f", "./fixtures/configs/compose.yaml", "run", "target"), |
| 52 | func(cmd *icmd.Cmd) { |
| 53 | cmd.Env = append(cmd.Env, "CONFIG=config") |
| 54 | }) |
| 55 | res.Assert(t, icmd.Expected{Out: "This is my config"}) |
| 56 | }) |
| 57 | } |
nothing calls this directly
no test coverage detected