Skip to content

Commit 327be1f

Browse files
htoyoda18ndeloof
authored andcommitted
add unit test
Signed-off-by: hiroto.toyoda <hiroto.toyoda@dena.com>
1 parent 59f04b8 commit 327be1f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

cmd/compose/up_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121

2222
"github.com/compose-spec/compose-go/v2/types"
2323
"gotest.tools/v3/assert"
24+
25+
"github.com/docker/compose/v5/pkg/api"
2426
)
2527

2628
func TestApplyScaleOpt(t *testing.T) {
@@ -48,3 +50,42 @@ func TestApplyScaleOpt(t *testing.T) {
4850
assert.Equal(t, *bar.Scale, 3)
4951
assert.Equal(t, *bar.Deploy.Replicas, 3)
5052
}
53+
54+
func TestUpOptions_OnExit(t *testing.T) {
55+
tests := []struct {
56+
name string
57+
args upOptions
58+
want api.Cascade
59+
}{
60+
{
61+
name: "no cascade",
62+
args: upOptions{},
63+
want: api.CascadeIgnore,
64+
},
65+
{
66+
name: "cascade stop",
67+
args: upOptions{cascadeStop: true},
68+
want: api.CascadeStop,
69+
},
70+
{
71+
name: "cascade fail",
72+
args: upOptions{cascadeFail: true},
73+
want: api.CascadeFail,
74+
},
75+
{
76+
name: "both set - stop takes precedence",
77+
args: upOptions{
78+
cascadeStop: true,
79+
cascadeFail: true,
80+
},
81+
want: api.CascadeStop,
82+
},
83+
}
84+
85+
for _, tt := range tests {
86+
t.Run(tt.name, func(t *testing.T) {
87+
got := tt.args.OnExit()
88+
assert.Equal(t, got, tt.want)
89+
})
90+
}
91+
}

0 commit comments

Comments
 (0)