From fb320dc22f21f7c76bebbc61b74483107dc75c72 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Thu, 24 Oct 2019 15:49:28 +0200 Subject: [PATCH] e2e test to check parameters validation Signed-off-by: Nicolas De Loof --- .../docker-compose.yml | 29 +++++++++++++++++++ .../unused_parameter.dockerapp/metadata.yml | 8 +++++ .../unused_parameter.dockerapp/parameters.yml | 7 +++++ e2e/validate_test.go | 19 ++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 e2e/testdata/invalid/unused_parameter.dockerapp/docker-compose.yml create mode 100644 e2e/testdata/invalid/unused_parameter.dockerapp/metadata.yml create mode 100644 e2e/testdata/invalid/unused_parameter.dockerapp/parameters.yml create mode 100644 e2e/validate_test.go diff --git a/e2e/testdata/invalid/unused_parameter.dockerapp/docker-compose.yml b/e2e/testdata/invalid/unused_parameter.dockerapp/docker-compose.yml new file mode 100644 index 000000000..165694ddb --- /dev/null +++ b/e2e/testdata/invalid/unused_parameter.dockerapp/docker-compose.yml @@ -0,0 +1,29 @@ +version: "3.6" +services: + api: + image: python:3.6 + networks: + back: + front: + aliases: + - api.example.com + - ${api.host} + web: + image: nginx:latest + networks: + - front + volumes: + - static:/opt/${static_subdir} + ports: + - ${web.port}:80 + db: + image: postgres:9.3 + networks: + - back +networks: + front: + back: +volumes: + static: + external: true + name: corp/web-static-data diff --git a/e2e/testdata/invalid/unused_parameter.dockerapp/metadata.yml b/e2e/testdata/invalid/unused_parameter.dockerapp/metadata.yml new file mode 100644 index 000000000..c09a25fc2 --- /dev/null +++ b/e2e/testdata/invalid/unused_parameter.dockerapp/metadata.yml @@ -0,0 +1,8 @@ +version: 1.1.0-beta1 +name: simple +description: "new fancy webapp with microservices" +maintainers: + - name: John Developer + email: john.dev@example.com + - name: Jane Developer + email: jane.dev@example.com diff --git a/e2e/testdata/invalid/unused_parameter.dockerapp/parameters.yml b/e2e/testdata/invalid/unused_parameter.dockerapp/parameters.yml new file mode 100644 index 000000000..949bae74b --- /dev/null +++ b/e2e/testdata/invalid/unused_parameter.dockerapp/parameters.yml @@ -0,0 +1,7 @@ +web: + port: '8082' +api: + host: example.com +static_subdir: data/static +unused: + parameter: FOO diff --git a/e2e/validate_test.go b/e2e/validate_test.go new file mode 100644 index 000000000..300c4320e --- /dev/null +++ b/e2e/validate_test.go @@ -0,0 +1,19 @@ +package e2e + +import ( + "path" + "testing" + + "gotest.tools/assert" + + "gotest.tools/icmd" +) + +func TestOrphanedParameter(t *testing.T) { + cmd, cleanup := dockerCli.createTestCmd() + defer cleanup() + p := path.Join("testdata", "invalid", "unused_parameter") + cmd.Command = dockerCli.Command("app", "validate", p) + out := icmd.RunCmd(cmd).Assert(t, icmd.Expected{ExitCode: 1}).Combined() + assert.Equal(t, out, "unused.parameter is declared as parameter but not used by the compose file") +}