MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestAppNeedsRootlessParentMain

Function TestAppNeedsRootlessParentMain

cmd/nerdctl/main_linux_test.go:27–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestAppNeedsRootlessParentMain(t *testing.T) {
28 if !rootlessutil.IsRootlessParent() {
29 t.Skip("test requires a rootless parent context")
30 }
31
32 app, err := newApp()
33 assert.NilError(t, err)
34
35 tests := []struct {
36 name string
37 path []string
38 expected bool
39 }{
40 {
41 name: "root help path does not require reexec",
42 path: nil,
43 expected: false,
44 },
45 {
46 name: "management command help path does not require reexec",
47 path: []string{"system"},
48 expected: false,
49 },
50 {
51 name: "runtime command still requires reexec",
52 path: []string{"system", "info"},
53 expected: true,
54 },
55 }
56
57 for _, tc := range tests {
58 t.Run(tc.name, func(t *testing.T) {
59 cmd := app
60 args := []string{}
61 if len(tc.path) > 0 {
62 var findErr error
63 cmd, args, findErr = app.Find(tc.path)
64 assert.NilError(t, findErr)
65 }
66 assert.Equal(t, appNeedsRootlessParentMain(cmd, args), tc.expected)
67 })
68 }
69}

Callers

nothing calls this directly

Calls 5

IsRootlessParentFunction · 0.92
newAppFunction · 0.85
SkipMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…