|
|
@ -17,11 +17,14 @@ package downloader
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"bytes"
|
|
|
|
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"reflect"
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/internal/third_party/dep/fs"
|
|
|
|
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/pkg/chart"
|
|
|
|
"helm.sh/helm/v3/pkg/chart"
|
|
|
|
"helm.sh/helm/v3/pkg/chartutil"
|
|
|
|
"helm.sh/helm/v3/pkg/chartutil"
|
|
|
|
"helm.sh/helm/v3/pkg/getter"
|
|
|
|
"helm.sh/helm/v3/pkg/getter"
|
|
|
@ -188,22 +191,29 @@ func TestDownloadAll(t *testing.T) {
|
|
|
|
// 2nd downloadAll copies existing charts to tmpcharts and fails but tmpcharts folder will be removed
|
|
|
|
// 2nd downloadAll copies existing charts to tmpcharts and fails but tmpcharts folder will be removed
|
|
|
|
// 3rd downloadAll again runs with another dependency
|
|
|
|
// 3rd downloadAll again runs with another dependency
|
|
|
|
b := bytes.NewBuffer(nil)
|
|
|
|
b := bytes.NewBuffer(nil)
|
|
|
|
|
|
|
|
testDir, _ := ioutil.TempDir("", "helm-manager-test-*")
|
|
|
|
m := &Manager{
|
|
|
|
m := &Manager{
|
|
|
|
Out: b,
|
|
|
|
Out: b,
|
|
|
|
RepositoryConfig: repoConfig,
|
|
|
|
RepositoryConfig: repoConfig,
|
|
|
|
RepositoryCache: repoCache,
|
|
|
|
RepositoryCache: repoCache,
|
|
|
|
|
|
|
|
ChartPath: testDir,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// remove charts folder at the end of test
|
|
|
|
// remove Chart folder at the end of test
|
|
|
|
defer os.RemoveAll("charts")
|
|
|
|
defer os.RemoveAll(testDir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testChartPath := "./testdata/signtest"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Copy the test chart to our testing area
|
|
|
|
|
|
|
|
fs.CopyDir(testChartPath, filepath.Join(testDir, testChartPath))
|
|
|
|
|
|
|
|
|
|
|
|
// call downloadAll so that it will create charts directory
|
|
|
|
// call downloadAll so that it will create charts directory
|
|
|
|
err := m.downloadAll([]*chart.Dependency{
|
|
|
|
err := m.downloadAll([]*chart.Dependency{
|
|
|
|
{Name: "local-dep", Repository: "file://./testdata/signtest", Version: "0.1.0"},
|
|
|
|
{Name: "local-dep", Repository: "file://" + testChartPath, Version: "0.1.0"},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// this will copy charts directory content to tmp directory and recreates new charts
|
|
|
|
// this will copy charts directory content to tmp directory and recreate new charts
|
|
|
|
err = m.downloadAll([]*chart.Dependency{
|
|
|
|
err = m.downloadAll([]*chart.Dependency{
|
|
|
|
{Name: "local-subchart", Repository: ""},
|
|
|
|
{Name: "local-subchart", Repository: ""},
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -211,7 +221,7 @@ func TestDownloadAll(t *testing.T) {
|
|
|
|
t.Fatal(err)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err = m.downloadAll([]*chart.Dependency{
|
|
|
|
err = m.downloadAll([]*chart.Dependency{
|
|
|
|
{Name: "local-dep", Repository: "file://./testdata/signtest", Version: "0.1.0"},
|
|
|
|
{Name: "local-dep", Repository: "file://" + testChartPath, Version: "0.1.0"},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
t.Fatal(err)
|
|
|
|