MCPcopy
hub / github.com/helm/helm / TestRepoRemove

Function TestRepoRemove

pkg/cmd/repo_remove_test.go:32–141  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30)
31
32func TestRepoRemove(t *testing.T) {
33 ts := repotest.NewTempServer(
34 t,
35 repotest.WithChartSourceGlob("testdata/testserver/*.*"),
36 )
37 defer ts.Stop()
38
39 rootDir := t.TempDir()
40 repoFile := filepath.Join(rootDir, "repositories.yaml")
41
42 const testRepoName = "test-name"
43
44 b := bytes.NewBuffer(nil)
45
46 rmOpts := repoRemoveOptions{
47 names: []string{testRepoName},
48 repoFile: repoFile,
49 repoCache: rootDir,
50 }
51
52 if err := rmOpts.run(os.Stderr); err == nil {
53 t.Errorf("Expected error removing %s, but did not get one.", testRepoName)
54 }
55 o := &repoAddOptions{
56 name: testRepoName,
57 url: ts.URL(),
58 repoFile: repoFile,
59 }
60
61 if err := o.run(os.Stderr); err != nil {
62 t.Error(err)
63 }
64
65 cacheIndexFile, cacheChartsFile := createCacheFiles(rootDir, testRepoName)
66
67 // Reset the buffer before running repo remove
68 b.Reset()
69
70 if err := rmOpts.run(b); err != nil {
71 t.Errorf("Error removing %s from repositories", testRepoName)
72 }
73 if !strings.Contains(b.String(), "has been removed") {
74 t.Errorf("Unexpected output: %s", b.String())
75 }
76
77 testCacheFiles(t, cacheIndexFile, cacheChartsFile, testRepoName)
78
79 f, err := repo.LoadFile(repoFile)
80 if err != nil {
81 t.Error(err)
82 }
83
84 if f.Has(testRepoName) {
85 t.Errorf("%s was not successfully removed from repositories list", testRepoName)
86 }
87
88 // Test removal of multiple repos in one go
89 var testRepoNames = []string{"foo", "bar", "baz"}

Callers

nothing calls this directly

Calls 12

runMethod · 0.95
runMethod · 0.95
NewTempServerFunction · 0.92
WithChartSourceGlobFunction · 0.92
createCacheFilesFunction · 0.85
testCacheFilesFunction · 0.85
StopMethod · 0.80
URLMethod · 0.80
ContainsMethod · 0.80
ErrorMethod · 0.45
StringMethod · 0.45
HasMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…