|
|
@ -321,33 +321,37 @@ func verifyRequirementsImportValues(t *testing.T, c *chart.Chart, v *chart.Confi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestUpdateChartDependencyAlias(t *testing.T) {
|
|
|
|
func TestGetAliasDependency(t *testing.T) {
|
|
|
|
c, err := Load("testdata/frobnitz")
|
|
|
|
c, err := Load("testdata/frobnitz")
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed to load testdata: %s", err)
|
|
|
|
t.Fatalf("Failed to load testdata: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
req, err := LoadRequirements(c)
|
|
|
|
if aliasChart := updateChartDependencyAlias(c.Dependencies, "mariners", "another-mariner", false); aliasChart != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("expected no chart but got %s", aliasChart.Metadata.Name)
|
|
|
|
t.Fatalf("Failed to load requirement for testdata: %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(req.Dependencies) == 0 {
|
|
|
|
|
|
|
|
t.Fatalf("There are no requirements to test")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
aliasChart := updateChartDependencyAlias(c.Dependencies, "mariner", "another-mariner", false)
|
|
|
|
// Success case
|
|
|
|
|
|
|
|
aliasChart := getAliasDependency(c.Dependencies, req.Dependencies[0])
|
|
|
|
if aliasChart == nil {
|
|
|
|
if aliasChart == nil {
|
|
|
|
t.Fatal("Failed to find dependent chart")
|
|
|
|
t.Fatalf("Failed to get dependency chart for alias %s", req.Dependencies[0].Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if aliasChart.Metadata.Name != "another-mariner" {
|
|
|
|
if req.Dependencies[0].Alias != "" {
|
|
|
|
t.Fatal(`Failed to update chart-name for alias "dependent chart`)
|
|
|
|
if aliasChart.Metadata.Name != req.Dependencies[0].Alias {
|
|
|
|
|
|
|
|
t.Fatalf("Dependency chart name should be %s but got %s", req.Dependencies[0].Alias, aliasChart.Metadata.Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if aliasChart.Metadata.Name != req.Dependencies[0].Name {
|
|
|
|
//Testing single-alias update, first update and then try same with non-first alias, we should not be able to find chart
|
|
|
|
t.Fatalf("Dependency chart name should be %s but got %s", req.Dependencies[0].Name, aliasChart.Metadata.Name)
|
|
|
|
if aliasChart := updateChartDependencyAlias(c.Dependencies, "mariner", "another-mariner", true); aliasChart != nil {
|
|
|
|
|
|
|
|
t.Fatalf("expected no chart but got %s", aliasChart.Metadata.Name)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if aliasChart := updateChartDependencyAlias(c.Dependencies, "mariner", "another-mariner", false); aliasChart != nil {
|
|
|
|
// Failure case
|
|
|
|
|
|
|
|
req.Dependencies[0].Name = "something-else"
|
|
|
|
|
|
|
|
if aliasChart := getAliasDependency(c.Dependencies, req.Dependencies[0]); aliasChart != nil {
|
|
|
|
t.Fatalf("expected no chart but got %s", aliasChart.Metadata.Name)
|
|
|
|
t.Fatalf("expected no chart but got %s", aliasChart.Metadata.Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestDependentChartAliases(t *testing.T) {
|
|
|
|
func TestDependentChartAliases(t *testing.T) {
|
|
|
@ -374,15 +378,15 @@ func TestDependentChartAliases(t *testing.T) {
|
|
|
|
t.Fatalf("Cannot load requirements for test chart, %v", err)
|
|
|
|
t.Fatalf("Cannot load requirements for test chart, %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var expectedDependencyCharts int
|
|
|
|
// var expectedDependencyCharts int
|
|
|
|
for _, reqmt := range reqmts.Dependencies {
|
|
|
|
// for _, reqmt := range reqmts.Dependencies {
|
|
|
|
expectedDependencyCharts++
|
|
|
|
// expectedDependencyCharts++
|
|
|
|
if len(reqmt.Alias) >= 0 {
|
|
|
|
// if len(reqmt.Alias) >= 0 {
|
|
|
|
expectedDependencyCharts += len(reqmt.Alias)
|
|
|
|
// expectedDependencyCharts += len(reqmt.Alias)
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
if len(c.Dependencies) != expectedDependencyCharts-1 {
|
|
|
|
if len(c.Dependencies) != len(reqmts.Dependencies) {
|
|
|
|
t.Fatalf("Expected number of chart dependencies %d, but got %d", expectedDependencyCharts-1, len(c.Dependencies))
|
|
|
|
t.Fatalf("Expected number of chart dependencies %d, but got %d", len(reqmts.Dependencies), len(c.Dependencies))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|