|
// https://github.com/containerd/nerdctl/issues/2598 |
|
func TestContainerListWithFormatLabel(t *testing.T) { |
|
t.Parallel() |
|
base := testutil.NewBase(t) |
|
tID := testutil.Identifier(t) |
|
cID := tID |
|
labelK := "label-key-" + tID |
|
labelV := "label-value-" + tID |
|
|
|
base.Cmd("run", "-d", |
|
"--name", cID, |
|
"--label", labelK+"="+labelV, |
|
testutil.CommonImage, "sleep", nerdtest.Infinity).AssertOK() |
|
defer base.Cmd("rm", "-f", cID).AssertOK() |
|
base.Cmd("ps", "-a", |
|
"--filter", "label="+labelK, |
|
"--format", fmt.Sprintf("{{.Label %q}}", labelK)).AssertOutExactly(labelV + "\n") |
|
} |
|
|
|
func TestContainerListWithJsonFormatLabel(t *testing.T) { |
|
t.Parallel() |
|
base := testutil.NewBase(t) |
|
tID := testutil.Identifier(t) |
|
cID := tID |
|
labelK := "label-key-" + tID |
|
labelV := "label-value-" + tID |
|
|
|
base.Cmd("run", "-d", |
|
"--name", cID, |
|
"--label", labelK+"="+labelV, |
|
testutil.CommonImage, "sleep", nerdtest.Infinity).AssertOK() |
|
defer base.Cmd("rm", "-f", cID).AssertOK() |
|
base.Cmd("ps", "-a", |
|
"--filter", "label="+labelK, |
|
"--format", "json").AssertOutContains(fmt.Sprintf("%s=%s", labelK, labelV)) |
|
} |
All the tests using
testutil.NewBaseshould be rewritten to usenerdtest.Setup(i.e., Tigron framework)https://github.com/search?q=repo%3Acontainerd%2Fnerdctl%20testutil.NewBase&type=code
https://github.com/search?q=repo%3Acontainerd%2Fnerdctl+nerdtest.Setup&type=code
Example occurrence:
nerdctl/cmd/nerdctl/container/container_list_test.go
Lines 27 to 62 in 1d69ed9
Example PR:
Similar PRs:
This is a "good first issue", but needs a bunch of PRs.
Important
It is highly recommended to begin with updating a single short file.
Files (46)