@@ -57,3 +57,53 @@ func TestExplicitProfileUsage(t *testing.T) {
57
57
assert .Assert (t , ! strings .Contains (res .Combined (), projectName ), res .Combined ())
58
58
})
59
59
}
60
+
61
+ func TestNoProfileUsage (t * testing.T ) {
62
+ c := NewParallelCLI (t )
63
+ const projectName = "compose-e2e-no-profiles"
64
+
65
+ t .Run ("compose up without profile" , func (t * testing.T ) {
66
+ res := c .RunDockerComposeCmd (t , "-f" , "./fixtures/profiles/compose.yaml" ,
67
+ "-p" , projectName , "up" , "-d" )
68
+ res .Assert (t , icmd.Expected {ExitCode : 0 })
69
+ res = c .RunDockerComposeCmd (t , "-p" , projectName , "ps" )
70
+ res .Assert (t , icmd.Expected {Out : "main" })
71
+ assert .Assert (t , ! strings .Contains (res .Combined (), "profiled-service" ))
72
+ })
73
+
74
+ t .Run ("compose stop without profile" , func (t * testing.T ) {
75
+ res := c .RunDockerComposeCmd (t , "-f" , "./fixtures/profiles/compose.yaml" ,
76
+ "-p" , projectName , "stop" )
77
+ res .Assert (t , icmd.Expected {ExitCode : 0 })
78
+ res = c .RunDockerComposeCmd (t , "-p" , projectName , "ps" , "--status" , "running" )
79
+ assert .Assert (t , ! strings .Contains (res .Combined (), "profiled-service" ))
80
+ assert .Assert (t , ! strings .Contains (res .Combined (), "main" ))
81
+ })
82
+
83
+ t .Run ("compose start without profile" , func (t * testing.T ) {
84
+ res := c .RunDockerComposeCmd (t , "-f" , "./fixtures/profiles/compose.yaml" ,
85
+ "-p" , projectName , "start" )
86
+ res .Assert (t , icmd.Expected {ExitCode : 0 })
87
+ res = c .RunDockerComposeCmd (t , "-p" , projectName , "ps" , "--status" , "running" )
88
+ res .Assert (t , icmd.Expected {Out : "main" })
89
+ assert .Assert (t , ! strings .Contains (res .Combined (), "profiled-service" ))
90
+ })
91
+
92
+ t .Run ("compose restart without profile" , func (t * testing.T ) {
93
+ res := c .RunDockerComposeCmd (t , "-f" , "./fixtures/profiles/compose.yaml" ,
94
+ "-p" , projectName , "restart" )
95
+ res .Assert (t , icmd.Expected {ExitCode : 0 })
96
+ res = c .RunDockerComposeCmd (t , "-p" , projectName , "ps" , "--status" , "running" )
97
+ res .Assert (t , icmd.Expected {Out : "main" })
98
+ assert .Assert (t , ! strings .Contains (res .Combined (), "profiled-service" ))
99
+ })
100
+
101
+ t .Run ("down" , func (t * testing.T ) {
102
+ _ = c .RunDockerComposeCmd (t , "--project-name" , projectName , "down" )
103
+ })
104
+
105
+ t .Run ("check containers after down" , func (t * testing.T ) {
106
+ res := c .RunDockerCmd (t , "ps" , "--all" )
107
+ assert .Assert (t , ! strings .Contains (res .Combined (), projectName ), res .Combined ())
108
+ })
109
+ }
0 commit comments