Skip to content

Commit f3a3a37

Browse files
committed
add unit tests for channel validation stranding scenarios
1 parent a00c190 commit f3a3a37

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

alpha/model/model_test.go

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,48 @@ func TestValidReplacesChain(t *testing.T) {
156156
assertion: hasError(`detected cycle in replaces chain of upgrade graph: anakin.v0.0.3 -> anakin.v0.0.2 -> anakin.v0.0.1 -> anakin.v0.0.3`),
157157
},
158158
{
159-
name: "Error/Stranded",
159+
name: "Error/StrandedSkipsBeforeReplaces",
160160
ch: Channel{Bundles: map[string]*Bundle{
161161
"anakin.v0.0.1": {Name: "anakin.v0.0.1"},
162162
"anakin.v0.0.2": {Name: "anakin.v0.0.2", Replaces: "anakin.v0.0.1"},
163-
"anakin.v0.0.3": {Name: "anakin.v0.0.3", Skips: []string{"anakin.v0.0.2"}},
163+
"anakin.v0.0.3": {Name: "anakin.v0.0.3", Replaces: "anakin.v0.0.2"},
164+
"anakin.v0.0.4": {Name: "anakin.v0.0.4", Replaces: "anakin.v0.0.3"},
165+
"anakin.v0.0.5": {Name: "anakin.v0.0.5", Replaces: "anakin.v0.0.4", Skips: []string{"anakin.v0.0.3"}},
166+
}},
167+
assertion: hasError(`channel contains one or more stranded bundles: anakin.v0.0.1, anakin.v0.0.2`),
168+
},
169+
{
170+
name: "Error/StrandedSkipsWithReplaces",
171+
ch: Channel{Bundles: map[string]*Bundle{
172+
"anakin.v0.0.1": {Name: "anakin.v0.0.1"},
173+
"anakin.v0.0.2": {Name: "anakin.v0.0.2", Replaces: "anakin.v0.0.1"},
174+
"anakin.v0.0.3": {Name: "anakin.v0.0.3", Replaces: "anakin.v0.0.2"},
175+
"anakin.v0.0.4": {Name: "anakin.v0.0.4", Replaces: "anakin.v0.0.3", Skips: []string{"anakin.v0.0.3"}},
176+
"anakin.v0.0.5": {Name: "anakin.v0.0.5", Replaces: "anakin.v0.0.4"},
177+
}},
178+
assertion: hasError(`channel contains one or more stranded bundles: anakin.v0.0.1, anakin.v0.0.2`),
179+
},
180+
{
181+
name: "Error/StrandedSkipsAfterReplaces",
182+
ch: Channel{Bundles: map[string]*Bundle{
183+
"anakin.v0.0.1": {Name: "anakin.v0.0.1"},
184+
"anakin.v0.0.2": {Name: "anakin.v0.0.2", Replaces: "anakin.v0.0.1"},
185+
"anakin.v0.0.3": {Name: "anakin.v0.0.3", Replaces: "anakin.v0.0.2", Skips: []string{"anakin.v0.0.3"}},
186+
"anakin.v0.0.4": {Name: "anakin.v0.0.4", Replaces: "anakin.v0.0.3"},
187+
"anakin.v0.0.5": {Name: "anakin.v0.0.5", Replaces: "anakin.v0.0.4"},
188+
}},
189+
assertion: hasError(`channel contains one or more stranded bundles: anakin.v0.0.1, anakin.v0.0.2`),
190+
},
191+
{
192+
name: "Error/StrandedSkipsTheTail",
193+
ch: Channel{Bundles: map[string]*Bundle{
194+
"anakin.v0.0.1": {Name: "anakin.v0.0.1"},
195+
"anakin.v0.0.2": {Name: "anakin.v0.0.2", Replaces: "anakin.v0.0.1", Skips: []string{"anakin.v0.0.1"}},
196+
"anakin.v0.0.3": {Name: "anakin.v0.0.3", Replaces: "anakin.v0.0.2"},
197+
"anakin.v0.0.4": {Name: "anakin.v0.0.4", Replaces: "anakin.v0.0.3"},
198+
"anakin.v0.0.5": {Name: "anakin.v0.0.5", Replaces: "anakin.v0.0.4"},
164199
}},
165-
assertion: hasError(`channel contains one or more stranded bundles: anakin.v0.0.1`),
200+
assertion: require.NoError,
166201
},
167202
}
168203
for _, s := range specs {
@@ -196,7 +231,7 @@ func hasError(expectedError string) require.ErrorAssertionFunc {
196231
}
197232
}
198233
t.Errorf("expected error to be or contain suberror `%s`, got `%s`", expectedError, actualError)
199-
t.FailNow()
234+
//t.FailNow()
200235
}
201236
}
202237

0 commit comments

Comments
 (0)