@@ -203,6 +203,42 @@ func TestConvertToModel(t *testing.T) {
203203 Bundles : []Bundle {newTestBundle ("foo" , "0.1.0" )},
204204 },
205205 },
206+ {
207+ name : "Error/DuplicatePackage" ,
208+ assertion : hasError (`duplicate package "foo"` ),
209+ cfg : DeclarativeConfig {
210+ Packages : []Package {
211+ newTestPackage ("foo" , "alpha" , svgSmallCircle ),
212+ newTestPackage ("foo" , "alpha" , svgSmallCircle ),
213+ },
214+ Channels : []Channel {newTestChannel ("foo" , "alpha" , ChannelEntry {Name : "foo.v0.1.0" })},
215+ Bundles : []Bundle {newTestBundle ("foo" , "0.1.0" )},
216+ },
217+ },
218+ {
219+ name : "Error/DuplicateChannel" ,
220+ assertion : hasError (`package "foo" has duplicate channel "alpha"` ),
221+ cfg : DeclarativeConfig {
222+ Packages : []Package {newTestPackage ("foo" , "alpha" , svgSmallCircle )},
223+ Channels : []Channel {
224+ newTestChannel ("foo" , "alpha" , ChannelEntry {Name : "foo.v0.1.0" }),
225+ newTestChannel ("foo" , "alpha" , ChannelEntry {Name : "foo.v0.1.0" }),
226+ },
227+ Bundles : []Bundle {newTestBundle ("foo" , "0.1.0" )},
228+ },
229+ },
230+ {
231+ name : "Error/DuplicateBundle" ,
232+ assertion : hasError (`package "foo" has duplicate bundle "foo.v0.1.0"` ),
233+ cfg : DeclarativeConfig {
234+ Packages : []Package {newTestPackage ("foo" , "alpha" , svgSmallCircle )},
235+ Channels : []Channel {newTestChannel ("foo" , "alpha" , ChannelEntry {Name : "foo.v0.1.0" })},
236+ Bundles : []Bundle {
237+ newTestBundle ("foo" , "0.1.0" ),
238+ newTestBundle ("foo" , "0.1.0" ),
239+ },
240+ },
241+ },
206242 {
207243 name : "Success/ValidModel" ,
208244 assertion : require .NoError ,
@@ -242,7 +278,7 @@ func hasError(expectedError string) require.ErrorAssertionFunc {
242278 if stdt , ok := t .(* testing.T ); ok {
243279 stdt .Helper ()
244280 }
245- if actualError .Error () == expectedError {
281+ if actualError != nil && actualError .Error () == expectedError {
246282 return
247283 }
248284 t .Errorf ("expected error to be `%s`, got `%s`" , expectedError , actualError )
0 commit comments