MCPcopy Create free account
hub / github.com/containers/image / TestParseDefFile

Function TestParseDefFile

sif/load_test.go:11–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestParseDefFile(t *testing.T) {
12 for _, c := range []struct {
13 name string
14 input string
15 environment []string
16 runscript []string
17 }{
18 {"Empty input", "", []string{}, []string{}},
19 {
20 name: "Basic smoke test",
21 input: "Bootstrap: library\n" +
22 "%environment\n" +
23 " export FOO=world\n" +
24 " export BAR=baz\n" +
25 "%runscript\n" +
26 ` echo "Hello $FOO"` + "\n" +
27 " sleep 5\n" +
28 "%help\n" +
29 " Abandon all hope.\n",
30 environment: []string{"export FOO=world", "export BAR=baz"},
31 runscript: []string{`echo "Hello $FOO"`, "sleep 5"},
32 },
33 {
34 name: "Trailing section marker",
35 input: "Bootstrap: library\n" +
36 "%environment\n" +
37 " export FOO=world\n" +
38 "%runscript",
39 environment: []string{"export FOO=world"},
40 runscript: []string{},
41 },
42 } {
43 env, rs, err := parseDefFile(bytes.NewReader([]byte(c.input)))
44 require.NoError(t, err, c.name)
45 assert.Equal(t, c.environment, env, c.name)
46 assert.Equal(t, c.runscript, rs, c.name)
47 }
48}
49
50func TestGenerateInjectedScript(t *testing.T) {
51 res := generateInjectedScript([]string{"export FOO=world", "export BAR=baz"},

Callers

nothing calls this directly

Calls 1

parseDefFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…