MCPcopy Index your code
hub / github.com/helm/helm / TestPathValue

Function TestPathValue

pkg/chart/common/values_test.go:170–205  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

168}
169
170func TestPathValue(t *testing.T) {
171 doc := `
172title: "Moby Dick"
173chapter:
174 one:
175 title: "Loomings"
176 two:
177 title: "The Carpet-Bag"
178 three:
179 title: "The Spouter Inn"
180`
181 d, err := ReadValues([]byte(doc))
182 if err != nil {
183 t.Fatalf("Failed to parse the White Whale: %s", err)
184 }
185
186 if v, err := d.PathValue("chapter.one.title"); err != nil {
187 t.Errorf("Got error instead of title: %s\n%v", err, d)
188 } else if v != "Loomings" {
189 t.Errorf("No error but got wrong value for title: %s\n%v", err, d)
190 }
191 if _, err := d.PathValue("chapter.one.doesnotexist"); err == nil {
192 t.Errorf("Non-existent key should return error: %s\n%v", err, d)
193 }
194 if _, err := d.PathValue("chapter.doesnotexist.one"); err == nil {
195 t.Errorf("Non-existent key in middle of path should return error: %s\n%v", err, d)
196 }
197 if _, err := d.PathValue(""); err == nil {
198 t.Error("Asking for the value from an empty path should yield an error")
199 }
200 if v, err := d.PathValue("title"); err == nil {
201 if v != "Moby Dick" {
202 t.Error("Failed to return values for root key title")
203 }
204 }
205}

Callers

nothing calls this directly

Calls 4

ReadValuesFunction · 0.85
FatalfMethod · 0.80
PathValueMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…