| 44 | } |
| 45 | |
| 46 | func TestInfo(t *testing.T) { |
| 47 | testCase := nerdtest.Setup() |
| 48 | |
| 49 | // Note: some functions need to be tested without the automatic --namespace nerdctl-test argument, so we need |
| 50 | // to retrieve the binary name. |
| 51 | // Note that we know this works already, so no need to assert err. |
| 52 | bin, _ := exec.LookPath(testutil.GetTarget()) |
| 53 | |
| 54 | testCase.SubTests = []*test.Case{ |
| 55 | { |
| 56 | Description: "info", |
| 57 | Command: test.Command("info", "--format", "{{json .}}"), |
| 58 | Expected: test.Expects(0, nil, testInfoComparator), |
| 59 | }, |
| 60 | { |
| 61 | Description: "info convenience form", |
| 62 | Command: test.Command("info", "--format", "json"), |
| 63 | Expected: test.Expects(0, nil, testInfoComparator), |
| 64 | }, |
| 65 | { |
| 66 | Description: "info with namespace", |
| 67 | Require: require.Not(nerdtest.Docker), |
| 68 | Command: func(data test.Data, helpers test.Helpers) test.TestableCommand { |
| 69 | return helpers.Custom(bin, "info") |
| 70 | }, |
| 71 | Expected: test.Expects(0, nil, expect.Contains("Namespace: default")), |
| 72 | }, |
| 73 | { |
| 74 | Description: "info with namespace env var", |
| 75 | Env: map[string]string{ |
| 76 | "CONTAINERD_NAMESPACE": "test", |
| 77 | }, |
| 78 | Require: require.Not(nerdtest.Docker), |
| 79 | Command: func(data test.Data, helpers test.Helpers) test.TestableCommand { |
| 80 | return helpers.Custom(bin, "info") |
| 81 | }, |
| 82 | Expected: test.Expects(0, nil, expect.Contains("Namespace: test")), |
| 83 | }, |
| 84 | } |
| 85 | |
| 86 | testCase.Run(t) |
| 87 | } |