Пример #1
0
func TestRepoAddCmd(t *testing.T) {
	srv, thome, err := repotest.NewTempServer("testdata/testserver/*.*")
	if err != nil {
		t.Fatal(err)
	}

	oldhome := homePath()
	helmHome = thome
	defer func() {
		srv.Stop()
		helmHome = oldhome
		os.Remove(thome)
	}()
	if err := ensureTestHome(helmpath.Home(thome), t); err != nil {
		t.Fatal(err)
	}

	tests := []releaseCase{
		{
			name:     "add a repository",
			args:     []string{testName, srv.URL()},
			expected: testName + " has been added to your repositories",
		},
	}

	for _, tt := range tests {
		buf := bytes.NewBuffer(nil)
		c := newRepoAddCmd(buf)
		if err := c.RunE(c, tt.args); err != nil {
			t.Errorf("%q: expected %q, got %q", tt.name, tt.expected, err)
		}
	}
}
Пример #2
0
func TestRepoAdd(t *testing.T) {
	ts, thome, err := repotest.NewTempServer("testdata/testserver/*.*")
	if err != nil {
		t.Fatal(err)
	}

	oldhome := homePath()
	helmHome = thome
	hh := helmpath.Home(thome)
	defer func() {
		ts.Stop()
		helmHome = oldhome
		os.Remove(thome)
	}()
	if err := ensureTestHome(hh, t); err != nil {
		t.Fatal(err)
	}

	if err := addRepository(testName, ts.URL(), hh); err != nil {
		t.Error(err)
	}

	f, err := repo.LoadRepositoriesFile(hh.RepositoryFile())
	if err != nil {
		t.Error(err)
	}

	if !f.Has(testName) {
		t.Errorf("%s was not successfully inserted into %s", testName, hh.RepositoryFile())
	}
}
Пример #3
0
func TestUpdateCharts(t *testing.T) {
	srv, thome, err := repotest.NewTempServer("testdata/testserver/*.*")
	if err != nil {
		t.Fatal(err)
	}

	oldhome := homePath()
	helmHome = thome
	defer func() {
		srv.Stop()
		helmHome = oldhome
		os.Remove(thome)
	}()
	if err := ensureTestHome(helmpath.Home(thome), t); err != nil {
		t.Fatal(err)
	}

	buf := bytes.NewBuffer(nil)
	repos := []*repo.Entry{
		{Name: "charts", URL: srv.URL()},
	}
	updateCharts(repos, false, buf, helmpath.Home(thome))

	got := buf.String()
	if strings.Contains(got, "Unable to get an update") {
		t.Errorf("Failed to get a repo: %q", got)
	}
	if !strings.Contains(got, "Update Complete.") {
		t.Errorf("Update was not successful")
	}
}