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

Function TestDisallowDirectLibraryLoading

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

Source from the content-addressed store, hash-verified

313}
314
315func TestDisallowDirectLibraryLoading(t *testing.T) {
316 yamlTplData := []byte(`#@ load("_ytt_lib/data.lib.star", "data")`)
317
318 expectedErr := `
319- cannot load _ytt_lib/data.lib.star: Expected to find file '_ytt_lib/data.lib.star', but did not: Encountered private library '_ytt_lib'
320 in <toplevel>
321 tpl.yml:1 | #@ load("_ytt_lib/data.lib.star", "data")`
322
323 filesToProcess := []*files.File{
324 files.MustNewFileFromSource(files.NewBytesSource("tpl.yml", yamlTplData)),
325 files.MustNewFileFromSource(files.NewBytesSource("_ytt_lib/data.lib.star", []byte("data = 3"))),
326 }
327
328 ui := ui.NewTTY(false)
329 opts := cmdtpl.NewOptions()
330
331 out := opts.RunWithFiles(cmdtpl.Input{Files: filesToProcess}, ui)
332 require.EqualError(t, out.Err, expectedErr)
333}
334
335func TestRelativeLoadInLibraries(t *testing.T) {
336 yamlTplData := []byte(`

Callers

nothing calls this directly

Calls 3

RunWithFilesMethod · 0.95
MustNewFileFromSourceFunction · 0.92
NewBytesSourceFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…