|
|
|
@ -18,14 +18,15 @@ package main
|
|
|
|
|
import (
|
|
|
|
|
"bytes"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io"
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/internal/test/ensure"
|
|
|
|
|
"helm.sh/helm/v3/pkg/getter"
|
|
|
|
|
"helm.sh/helm/v3/pkg/repo"
|
|
|
|
|
"helm.sh/helm/v3/pkg/repo/repotest"
|
|
|
|
|
"io"
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestUpdateCmd(t *testing.T) {
|
|
|
|
@ -79,3 +80,34 @@ func TestUpdateCharts(t *testing.T) {
|
|
|
|
|
t.Error("Update was not successful")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestUpdateChartsCustomCache(t *testing.T) {
|
|
|
|
|
defer resetEnv()()
|
|
|
|
|
defer ensure.HelmHome(t)()
|
|
|
|
|
|
|
|
|
|
ts, err := repotest.NewTempServer("testdata/testserver/*.*")
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
defer ts.Stop()
|
|
|
|
|
|
|
|
|
|
r, err := repo.NewChartRepository(&repo.Entry{
|
|
|
|
|
Name: "charts",
|
|
|
|
|
URL: ts.URL(),
|
|
|
|
|
}, getter.All(settings))
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cachePath := ensure.TempDir(t)
|
|
|
|
|
cacheFile := filepath.Join(cachePath, "charts-index.yaml")
|
|
|
|
|
r.CachePath = cachePath
|
|
|
|
|
|
|
|
|
|
b := bytes.NewBuffer(nil)
|
|
|
|
|
updateCharts([]*repo.ChartRepository{r}, b)
|
|
|
|
|
|
|
|
|
|
_, err = ioutil.ReadFile(cacheFile)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error(err)
|
|
|
|
|
}
|
|
|
|
|
}
|