|
|
|
@ -298,24 +298,6 @@ version: 0.1.0`
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("Expected error for bad dependency name")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
remoteDep := &chart.Dependency{
|
|
|
|
|
Name: "sub",
|
|
|
|
|
Repository: "oci://remote",
|
|
|
|
|
Version: "0.0.1",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// create a 'tmpcharts' directory to test #30710
|
|
|
|
|
if err := os.MkdirAll(filepath.Join(chartPath, "charts", "sub"), 0755); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
err = m.downloadAll([]*chart.Dependency{remoteDep})
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("Expected error as subchart already exist")
|
|
|
|
|
}
|
|
|
|
|
if err.Error() != "dependency conflict detected: A subchart named 'sub' already exists in charts/ directory" {
|
|
|
|
|
t.Fatal("Download should failed with conflict issue")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestUpdateBeforeBuild(t *testing.T) {
|
|
|
|
@ -690,3 +672,53 @@ func TestDedupeRepos(t *testing.T) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCheckSubchartConflict(t *testing.T) {
|
|
|
|
|
chartPath := t.TempDir()
|
|
|
|
|
m := &Manager{
|
|
|
|
|
Out: new(bytes.Buffer),
|
|
|
|
|
RepositoryConfig: repoConfig,
|
|
|
|
|
RepositoryCache: repoCache,
|
|
|
|
|
ChartPath: chartPath,
|
|
|
|
|
}
|
|
|
|
|
// create a 'tmpcharts' directory to test #30710
|
|
|
|
|
if err := os.MkdirAll(filepath.Join(chartPath, "charts", "existing"), 0755); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Conflict use case, there is already a 'existing' directory in charts/.
|
|
|
|
|
existingDep := &chart.Dependency{
|
|
|
|
|
Name: "existing",
|
|
|
|
|
Repository: "oci://remote",
|
|
|
|
|
Version: "0.0.1",
|
|
|
|
|
}
|
|
|
|
|
err := m.checkSubchartConflict([]*chart.Dependency{existingDep})
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("Expected error as subchart already exist")
|
|
|
|
|
}
|
|
|
|
|
if err.Error() != "dependency conflict detected: A subchart named 'existing' already exists in charts/ directory" {
|
|
|
|
|
t.Fatal("checkSubchartConflict should failed with conflict issue")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// There is no exiting subchart with 'inexisting' name.
|
|
|
|
|
inexistingDep := &chart.Dependency{
|
|
|
|
|
Name: "inexisting",
|
|
|
|
|
Repository: "oci://remote",
|
|
|
|
|
Version: "0.0.1",
|
|
|
|
|
}
|
|
|
|
|
err = m.checkSubchartConflict([]*chart.Dependency{inexistingDep})
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal("checkSubchartConflict should failed not failed")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// No repository use case, means the chart is already in charts directory.
|
|
|
|
|
existingDep = &chart.Dependency{
|
|
|
|
|
Name: "existing",
|
|
|
|
|
Repository: "",
|
|
|
|
|
Version: "0.0.1",
|
|
|
|
|
}
|
|
|
|
|
err = m.checkSubchartConflict([]*chart.Dependency{existingDep})
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal("checkSubchartConflict should failed not failed")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|