MCPcopy
hub / github.com/helm/helm / TestCreate_Overwrite

Function TestCreate_Overwrite

pkg/chart/v2/util/create_test.go:113–145  ·  view source on GitHub ↗

TestCreate_Overwrite is a regression test for making sure that files are overwritten.

(t *testing.T)

Source from the content-addressed store, hash-verified

111
112// TestCreate_Overwrite is a regression test for making sure that files are overwritten.
113func TestCreate_Overwrite(t *testing.T) {
114 tdir := t.TempDir()
115
116 var errlog bytes.Buffer
117
118 if _, err := Create("foo", tdir); err != nil {
119 t.Fatal(err)
120 }
121
122 dir := filepath.Join(tdir, "foo")
123
124 tplname := filepath.Join(dir, "templates/hpa.yaml")
125 writeFile(tplname, []byte("FOO"))
126
127 // Now re-run the create
128 Stderr = &errlog
129 if _, err := Create("foo", tdir); err != nil {
130 t.Fatal(err)
131 }
132
133 data, err := os.ReadFile(tplname)
134 if err != nil {
135 t.Fatal(err)
136 }
137
138 if string(data) == "FOO" {
139 t.Fatal("File that should have been modified was not.")
140 }
141
142 if errlog.Len() == 0 {
143 t.Error("Expected warnings about overwriting files.")
144 }
145}
146
147func TestValidateChartName(t *testing.T) {
148 for name, shouldPass := range map[string]bool{

Callers

nothing calls this directly

Calls 5

FatalMethod · 0.80
CreateFunction · 0.70
writeFileFunction · 0.70
LenMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…