|
| 1 | +/* |
| 2 | + Copyright 2023 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 | + "time" |
| 23 | + |
| 24 | + "gotest.tools/v3/assert" |
| 25 | + "gotest.tools/v3/icmd" |
| 26 | +) |
| 27 | + |
| 28 | +func TestStartInterval(t *testing.T) { |
| 29 | + c := NewParallelCLI(t) |
| 30 | + const projectName = "e2e-start-interval" |
| 31 | + |
| 32 | + t.Cleanup(func() { |
| 33 | + c.cleanupWithDown(t, projectName) |
| 34 | + }) |
| 35 | + |
| 36 | + res := c.RunDockerComposeCmdNoCheck(t, "-f", "fixtures/start_interval/compose.yaml", "--project-name", projectName, "up", "--wait", "-d", "error") |
| 37 | + res.Assert(t, icmd.Expected{ExitCode: 1, Err: "healthcheck.start_interval requires healthcheck.start_period to be set"}) |
| 38 | + |
| 39 | + timeout := time.After(30 * time.Second) |
| 40 | + done := make(chan bool) |
| 41 | + go func() { |
| 42 | + res := c.RunDockerComposeCmd(t, "-f", "fixtures/start_interval/compose.yaml", "--project-name", projectName, "up", "--wait", "-d", "test") |
| 43 | + out := res.Combined() |
| 44 | + assert.Assert(t, strings.Contains(out, "Healthy"), out) |
| 45 | + done <- true |
| 46 | + }() |
| 47 | + |
| 48 | + select { |
| 49 | + case <-timeout: |
| 50 | + t.Fatal("test did not finish in time") |
| 51 | + case <-done: |
| 52 | + break |
| 53 | + } |
| 54 | +} |
0 commit comments