MCPcopy
hub / github.com/carvel-dev/ytt / TestDataListRelativeToLibraryRoot

Function TestDataListRelativeToLibraryRoot

pkg/cmd/template/cmd_test.go:149–224  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

147}
148
149func TestDataListRelativeToLibraryRoot(t *testing.T) {
150 yamlTplData := []byte(`
151#@ load("@ytt:data", "data")
152#@ load("funcs/funcs.lib.yml", "nested_data_list", "nested_data_read")
153
154rootlist: #@ data.list("/")
155rootdata: #@ data.read("/funcs/data")
156
157nestedlist: #@ nested_data_list()
158nesteddata: #@ nested_data_read()`)
159
160 yamlFuncsTplData := []byte(`
161#@ load("@ytt:data", "data")
162#@ load("funcs.lib.yml", "nested_data_list", "nested_data_read")
163
164rootlist: #@ data.list("/")
165rootdata: #@ data.read("/funcs/data")
166
167nestedlist: #@ nested_data_list()
168nesteddata: #@ nested_data_read()
169`)
170
171 expectedYAMLTplData := `rootlist:
172- /tpl.yml
173- /funcs/funcs.lib.yml
174- /funcs/tpl.yml
175- /funcs/data
176rootdata: |-
177 data
178 data
179nestedlist:
180 list:
181 - /tpl.yml
182 - /funcs/funcs.lib.yml
183 - /funcs/tpl.yml
184 - /funcs/data
185nesteddata:
186 data: |-
187 data
188 data
189`
190
191 yamlFuncsData := []byte(`
192#@ load("@ytt:data", "data")
193
194#@ def/end nested_data_list():
195list: #@ data.list("/")
196
197#@ def/end nested_data_read():
198data: #@ data.read("/funcs/data")`)
199
200 filesToProcess := files.NewSortedFiles([]*files.File{
201 files.MustNewFileFromSource(files.NewBytesSource("tpl.yml", yamlTplData)),
202 files.MustNewFileFromSource(files.NewBytesSource("funcs/funcs.lib.yml", yamlFuncsData)),
203 files.MustNewFileFromSource(files.NewBytesSource("funcs/tpl.yml", yamlFuncsTplData)),
204 files.MustNewFileFromSource(files.NewBytesSource("funcs/data", []byte("data\ndata"))),
205 files.MustNewFileFromSource(files.NewBytesSource("_ytt_lib/lib1/other", []byte("lib1\ndata"))),
206 })

Callers

nothing calls this directly

Calls 7

RunWithFilesMethod · 0.95
NewSortedFilesFunction · 0.92
MustNewFileFromSourceFunction · 0.92
NewBytesSourceFunction · 0.92
RelativePathMethod · 0.65
BytesMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…