(t *testing.T)
| 25 | ) |
| 26 | |
| 27 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…