New ๐ŸŒŠ wave for @helm

Commit 5c4c16b1

5c4c16b1fedeMerged

Svyatoslav Dumchenko <[email protected]> ยท 5 years ago ยท 1 file ยท ~1 modified

Description

add more tests

Details

Commit
5c4c16b1fede
Parent
792fa6c42b7d

pkg/release/plan_test.gomodifiedView file

@@ -3,6 +3,7 @@
33 package release
44
55 import (
6+ "helm.sh/helm/v3/pkg/action"
67 "reflect"
78 "testing"
89 )
@@ -106,3 +107,71 @@
106107 })
107108 }
108109 }
110+
111+func TestPlan(t *testing.T) {
112+ type args struct {
113+ tags []string
114+ enableDependencies bool
115+ }
116+
117+ releases := []*Config{
118+ {
119+ Name: "release1",
120+ Tags: []string{"1"},
121+ Options: action.Upgrade{
122+ Namespace: "ns",
123+ },
124+ DependsOn: []string{"release2@ns"},
125+ },
126+ {
127+ Name: "release2",
128+ Tags: []string{"2"},
129+ Options: action.Upgrade{
130+ Namespace: "ns",
131+ },
132+ },
133+ }
134+ tests := []struct {
135+ name string
136+ args args
137+ wantPlan []*Config
138+ }{
139+ {
140+ name: "empty tags",
141+ args: args{
142+ tags: []string{},
143+ },
144+ want: releases,
145+ },
146+ {
147+ name: "tag filter",
148+ args: args{
149+ tags: releases[0].Tags,
150+ enableDependencies: false,
151+ },
152+ want: []*Config{releases[0]},
153+ },
154+ {
155+ name: "nonexistent tag",
156+ args: args{
157+ tags: []string{"1231231"},
158+ },
159+ want: []*Config{},
160+ },
161+ {
162+ name: "add dependency",
163+ args: args{
164+ tags: releases[0].Tags,
165+ enableDependencies: true,
166+ },
167+ want: releases,
168+ },
169+ }
170+ for _, tt := range tests {
171+ t.Run(tt.name, func(t *testing.T) {
172+ if gotPlan := Plan(tt.args.tags, releases, tt.args.enableDependencies); !reflect.DeepEqual(gotPlan, tt.wantPlan) {
173+ t.Errorf("Plan() = %v, want %v", gotPlan, tt.wantPlan)
174+ }
175+ })
176+ }
177+}