From f0f47a8aa80e18f48b2e3887ac0494f8a5ba6fa9 Mon Sep 17 00:00:00 2001 From: Alessio Perugini Date: Tue, 6 May 2025 19:42:25 +0200 Subject: [PATCH] e2e: add tests Signed-off-by: Alessio Perugini --- cmd/compose/config.go | 2 +- pkg/e2e/config_test.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cmd/compose/config.go b/cmd/compose/config.go index e1121d3a8..a30c8fe70 100644 --- a/cmd/compose/config.go +++ b/cmd/compose/config.go @@ -416,7 +416,7 @@ func runVariables(ctx context.Context, dockerCli command.Cli, opts configOptions if err != nil { return err } - fmt.Println(string(result)) + fmt.Print(string(result)) return nil } diff --git a/pkg/e2e/config_test.go b/pkg/e2e/config_test.go index 6fef7bc02..15d3e3d93 100644 --- a/pkg/e2e/config_test.go +++ b/pkg/e2e/config_test.go @@ -46,4 +46,25 @@ func TestLocalComposeConfig(t *testing.T) { res := c.RunDockerComposeCmd(t, "-f", "./fixtures/config/compose.yaml", "--project-name", projectName, "config", "--no-interpolate") res.Assert(t, icmd.Expected{Out: `- ${PORT:-8080}:80`}) }) + + t.Run("--variables --format json", func(t *testing.T) { + res := c.RunDockerComposeCmd(t, "-f", "./fixtures/config/compose.yaml", "--project-name", projectName, "config", "--variables", "--format", "json") + res.Assert(t, icmd.Expected{Out: `{ + "PORT": { + "Name": "PORT", + "DefaultValue": "8080", + "PresenceValue": "", + "Required": false + } +}`}) + }) + + t.Run("--variables --format yaml", func(t *testing.T) { + res := c.RunDockerComposeCmd(t, "-f", "./fixtures/config/compose.yaml", "--project-name", projectName, "config", "--variables", "--format", "yaml") + res.Assert(t, icmd.Expected{Out: `PORT: + name: PORT + defaultvalue: "8080" + presencevalue: "" + required: false`}) + }) }