|
| 1 | +/* |
| 2 | + Copyright 2020 Docker Compose CLI authors |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package e2e |
| 18 | + |
| 19 | +import ( |
| 20 | + "strings" |
| 21 | + "testing" |
| 22 | + |
| 23 | + "gotest.tools/v3/assert" |
| 24 | + "gotest.tools/v3/icmd" |
| 25 | +) |
| 26 | + |
| 27 | +func TestPublishChecks(t *testing.T) { |
| 28 | + c := NewParallelCLI(t) |
| 29 | + const projectName = "compose-e2e-explicit-profiles" |
| 30 | + |
| 31 | + t.Run("publish error environment", func(t *testing.T) { |
| 32 | + res := c.RunDockerComposeCmdNoCheck(t, "-f", "./fixtures/publish/compose-environment.yml", |
| 33 | + "-p", projectName, "alpha", "publish", "test/test") |
| 34 | + res.Assert(t, icmd.Expected{ExitCode: 1, Err: `service "serviceA" has environment variable(s) declared. To avoid leaking sensitive data,`}) |
| 35 | + }) |
| 36 | + |
| 37 | + t.Run("publish error env_file", func(t *testing.T) { |
| 38 | + res := c.RunDockerComposeCmdNoCheck(t, "-f", "./fixtures/publish/compose-env-file.yml", |
| 39 | + "-p", projectName, "alpha", "publish", "test/test") |
| 40 | + res.Assert(t, icmd.Expected{ExitCode: 1, Err: `service "serviceA" has env_file declared. To avoid leaking sensitive data,`}) |
| 41 | + }) |
| 42 | + |
| 43 | + t.Run("publish success environment", func(t *testing.T) { |
| 44 | + res := c.RunDockerComposeCmd(t, "-f", "./fixtures/publish/compose-environment.yml", |
| 45 | + "-p", projectName, "alpha", "publish", "test/test", "--with-env", "--dry-run") |
| 46 | + assert.Assert(t, strings.Contains(res.Combined(), "test/test publishing"), res.Combined()) |
| 47 | + assert.Assert(t, strings.Contains(res.Combined(), "test/test published"), res.Combined()) |
| 48 | + }) |
| 49 | + |
| 50 | + t.Run("publish success env_file", func(t *testing.T) { |
| 51 | + res := c.RunDockerComposeCmd(t, "-f", "./fixtures/publish/compose-env-file.yml", |
| 52 | + "-p", projectName, "alpha", "publish", "test/test", "--with-env", "--dry-run") |
| 53 | + assert.Assert(t, strings.Contains(res.Combined(), "test/test publishing"), res.Combined()) |
| 54 | + assert.Assert(t, strings.Contains(res.Combined(), "test/test published"), res.Combined()) |
| 55 | + }) |
| 56 | +} |
0 commit comments