@@ -321,23 +321,33 @@ func verifyRequirementsImportValues(t *testing.T, c *chart.Chart, v *chart.Confi
321
321
}
322
322
}
323
323
324
- func TestCopyChartAsAlias (t * testing.T ) {
324
+ func TestUpdateChartDependencyAlias (t * testing.T ) {
325
325
c , err := Load ("testdata/frobnitz" )
326
326
if err != nil {
327
327
t .Fatalf ("Failed to load testdata: %s" , err )
328
328
}
329
329
330
- if aliasChart := copyChartAsAlias (c .Dependencies , "mariners" , "another-mariner" ); aliasChart != nil {
330
+ if aliasChart := updateChartDependencyAlias (c .Dependencies , "mariners" , "another-mariner" , false ); aliasChart != nil {
331
331
t .Fatalf ("expected no chart but got %s" , aliasChart .Metadata .Name )
332
332
}
333
333
334
- aliasChart := copyChartAsAlias (c .Dependencies , "mariner" , "another-mariner" )
334
+ aliasChart := updateChartDependencyAlias (c .Dependencies , "mariner" , "another-mariner" , false )
335
335
if aliasChart == nil {
336
336
t .Fatal ("Failed to find dependent chart" )
337
337
}
338
338
if aliasChart .Metadata .Name != "another-mariner" {
339
339
t .Fatal (`Failed to update chart-name for alias "dependent chart` )
340
340
}
341
+
342
+ //Testing single-alias update, first update and then try same with non-first alias, we should not be able to find chart
343
+ if aliasChart := updateChartDependencyAlias (c .Dependencies , "mariner" , "another-mariner" , true ); aliasChart != nil {
344
+ t .Fatalf ("expected no chart but got %s" , aliasChart .Metadata .Name )
345
+ }
346
+
347
+ if aliasChart := updateChartDependencyAlias (c .Dependencies , "mariner" , "another-mariner" , false ); aliasChart != nil {
348
+ t .Fatalf ("expected no chart but got %s" , aliasChart .Metadata .Name )
349
+ }
350
+
341
351
}
342
352
343
353
func TestDependentChartAliases (t * testing.T ) {
@@ -371,8 +381,8 @@ func TestDependentChartAliases(t *testing.T) {
371
381
expectedDependencyCharts += len (reqmt .Alias )
372
382
}
373
383
}
374
- if len (c .Dependencies ) != expectedDependencyCharts {
375
- t .Fatalf ("Expected number of chart dependencies %d, but got %d" , expectedDependencyCharts , len (c .Dependencies ))
384
+ if len (c .Dependencies ) != expectedDependencyCharts - 1 {
385
+ t .Fatalf ("Expected number of chart dependencies %d, but got %d" , expectedDependencyCharts - 1 , len (c .Dependencies ))
376
386
}
377
387
378
388
}
0 commit comments