@@ -21,13 +21,21 @@ import (
21
21
"testing"
22
22
"time"
23
23
24
+ "gotest.tools/v3/icmd"
25
+
24
26
"gotest.tools/v3/assert"
25
27
)
26
28
27
29
func TestWaitOnFaster (t * testing.T ) {
28
30
const projectName = "e2e-wait-faster"
29
31
c := NewParallelCLI (t )
30
32
33
+ cleanup := func () {
34
+ c .RunDockerComposeCmd (t , "--project-name" , projectName , "down" , "--timeout=0" , "--remove-orphans" )
35
+ }
36
+ t .Cleanup (cleanup )
37
+ cleanup ()
38
+
31
39
c .RunDockerComposeCmd (t , "-f" , "./fixtures/wait/compose.yaml" , "--project-name" , projectName , "up" , "-d" )
32
40
c .RunDockerComposeCmd (t , "--project-name" , projectName , "wait" , "faster" )
33
41
}
@@ -36,6 +44,12 @@ func TestWaitOnSlower(t *testing.T) {
36
44
const projectName = "e2e-wait-slower"
37
45
c := NewParallelCLI (t )
38
46
47
+ cleanup := func () {
48
+ c .RunDockerComposeCmd (t , "--project-name" , projectName , "down" , "--timeout=0" , "--remove-orphans" )
49
+ }
50
+ t .Cleanup (cleanup )
51
+ cleanup ()
52
+
39
53
c .RunDockerComposeCmd (t , "-f" , "./fixtures/wait/compose.yaml" , "--project-name" , projectName , "up" , "-d" )
40
54
c .RunDockerComposeCmd (t , "--project-name" , projectName , "wait" , "slower" )
41
55
}
@@ -44,12 +58,27 @@ func TestWaitOnInfinity(t *testing.T) {
44
58
const projectName = "e2e-wait-infinity"
45
59
c := NewParallelCLI (t )
46
60
61
+ cleanup := func () {
62
+ c .RunDockerComposeCmd (t , "--project-name" , projectName , "down" , "--timeout=0" , "--remove-orphans" )
63
+ }
64
+ t .Cleanup (cleanup )
65
+ cleanup ()
66
+
47
67
c .RunDockerComposeCmd (t , "-f" , "./fixtures/wait/compose.yaml" , "--project-name" , projectName , "up" , "-d" )
48
68
69
+ cmd := c .NewDockerComposeCmd (t , "--project-name" , projectName , "wait" , "infinity" )
70
+ r := icmd .StartCmd (cmd )
71
+ assert .NilError (t , r .Error )
72
+ t .Cleanup (func () {
73
+ if r .Cmd .Process != nil {
74
+ _ = r .Cmd .Process .Kill ()
75
+ }
76
+ })
77
+
49
78
finished := make (chan struct {})
50
79
ticker := time .NewTicker (7 * time .Second )
51
80
go func () {
52
- c . RunDockerComposeCmd ( t , "--project-name" , projectName , "wait" , "infinity" )
81
+ _ = r . Cmd . Wait ( )
53
82
finished <- struct {}{}
54
83
}()
55
84
@@ -64,6 +93,12 @@ func TestWaitAndDrop(t *testing.T) {
64
93
const projectName = "e2e-wait-and-drop"
65
94
c := NewParallelCLI (t )
66
95
96
+ cleanup := func () {
97
+ c .RunDockerComposeCmd (t , "--project-name" , projectName , "down" , "--timeout=0" , "--remove-orphans" )
98
+ }
99
+ t .Cleanup (cleanup )
100
+ cleanup ()
101
+
67
102
c .RunDockerComposeCmd (t , "-f" , "./fixtures/wait/compose.yaml" , "--project-name" , projectName , "up" , "-d" )
68
103
c .RunDockerComposeCmd (t , "--project-name" , projectName , "wait" , "--down-project" , "faster" )
69
104
0 commit comments