Skip to content

Commit 481ebe6

Browse files
committed
Adapt nerdctl tests to removed comparator info parameter
Signed-off-by: apostasie <[email protected]>
1 parent c7d90f1 commit 481ebe6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+340
-340
lines changed

cmd/nerdctl/builder/builder_build_oci_layout_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,13 @@ CMD ["echo", "test-nerdctl-build-context-oci-layout"]`
100100
},
101101
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
102102
return &test.Expected{
103-
Output: func(stdout string, info string, t *testing.T) {
103+
Output: func(stdout string, t *testing.T) {
104104
assert.Assert(
105105
t,
106106
strings.Contains(
107107
helpers.Capture("run", "--rm", data.Identifier("child")),
108108
"test-nerdctl-build-context-oci-layout",
109109
),
110-
info,
111110
)
112111
},
113112
}

cmd/nerdctl/builder/builder_build_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ COPY %s /`, testFileName)
339339
},
340340
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
341341
return &test.Expected{
342-
Output: func(stdout, info string, t *testing.T) {
342+
Output: func(stdout string, t *testing.T) {
343343
// Expecting testFileName to exist inside the output target directory
344344
assert.Equal(t, data.Temp().Load(testFileName), testContent, "file content is identical")
345345
},
@@ -353,7 +353,7 @@ COPY %s /`, testFileName)
353353
},
354354
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
355355
return &test.Expected{
356-
Output: func(stdout, info string, t *testing.T) {
356+
Output: func(stdout string, t *testing.T) {
357357
assert.Equal(t, data.Temp().Load(testFileName), testContent, "file content is identical")
358358
},
359359
}
@@ -890,7 +890,7 @@ func TestBuildAttestation(t *testing.T) {
890890
},
891891
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
892892
return &test.Expected{
893-
Output: func(stdout, info string, t *testing.T) {
893+
Output: func(stdout string, t *testing.T) {
894894
data.Temp().Exists("dir-for-bom", testSBOMFileName)
895895
},
896896
}
@@ -912,7 +912,7 @@ func TestBuildAttestation(t *testing.T) {
912912
},
913913
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
914914
return &test.Expected{
915-
Output: func(stdout, info string, t *testing.T) {
915+
Output: func(stdout string, t *testing.T) {
916916
data.Temp().Exists("dir-for-prov", testProvenanceFileName)
917917
},
918918
}
@@ -935,7 +935,7 @@ func TestBuildAttestation(t *testing.T) {
935935
},
936936
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
937937
return &test.Expected{
938-
Output: func(stdout, info string, t *testing.T) {
938+
Output: func(stdout string, t *testing.T) {
939939
data.Temp().Exists("dir-for-attest", testSBOMFileName)
940940
data.Temp().Exists("dir-for-attest", testProvenanceFileName)
941941
},

cmd/nerdctl/compose/compose_config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ services:
111111
testCase.Expected = func(data test.Data, helpers test.Helpers) *test.Expected {
112112
return &test.Expected{
113113
ExitCode: 0,
114-
Output: func(stdout, info string, t *testing.T) {
114+
Output: func(stdout string, t *testing.T) {
115115
assert.Assert(t, data.Labels().Get("hash") != stdout, "hash should be different")
116116
},
117117
}

cmd/nerdctl/compose/compose_cp_linux_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ services:
7979
},
8080
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
8181
return &test.Expected{
82-
Output: func(stdout, info string, t *testing.T) {
82+
Output: func(stdout string, t *testing.T) {
8383
copied := data.Temp().Load("test-file2")
8484
assert.Equal(t, copied, testFileContent)
8585
},

cmd/nerdctl/compose/compose_create_linux_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ services:
6666
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
6767
return helpers.Command("compose", "-f", data.Labels().Get("composeYaml"), "ps", "svc0", "-a")
6868
},
69-
Expected: test.Expects(expect.ExitCodeSuccess, nil, func(stdout, info string, t *testing.T) {
69+
Expected: test.Expects(expect.ExitCodeSuccess, nil, func(stdout string, t *testing.T) {
7070
assert.Assert(t,
7171
strings.Contains(stdout, "created") || strings.Contains(stdout, "Created"),
7272
"stdout should contain `created`")
@@ -125,7 +125,7 @@ services:
125125
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
126126
return helpers.Command("compose", "-f", data.Labels().Get("composeYaml"), "ps", "svc0", "-a")
127127
},
128-
Expected: test.Expects(expect.ExitCodeSuccess, nil, func(stdout, info string, t *testing.T) {
128+
Expected: test.Expects(expect.ExitCodeSuccess, nil, func(stdout string, t *testing.T) {
129129
assert.Assert(t,
130130
strings.Contains(stdout, "created") || strings.Contains(stdout, "Created"),
131131
"stdout should contain `created`")
@@ -137,7 +137,7 @@ services:
137137
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
138138
return helpers.Command("compose", "-f", data.Labels().Get("composeYaml"), "ps", "svc1", "-a")
139139
},
140-
Expected: test.Expects(expect.ExitCodeSuccess, nil, func(stdout, info string, t *testing.T) {
140+
Expected: test.Expects(expect.ExitCodeSuccess, nil, func(stdout string, t *testing.T) {
141141
assert.Assert(t,
142142
strings.Contains(stdout, "created") || strings.Contains(stdout, "Created"),
143143
"stdout should contain `created`")

cmd/nerdctl/container/container_attach_linux_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestAttach(t *testing.T) {
6464
cmd.Run(&test.Expected{
6565
ExitCode: 0,
6666
Errors: []error{errors.New("read detach keys")},
67-
Output: func(stdout string, info string, t *testing.T) {
67+
Output: func(stdout string, t *testing.T) {
6868
assert.Assert(t, strings.Contains(helpers.Capture("inspect", "--format", "json", data.Identifier()), "\"Running\":true"))
6969
},
7070
})
@@ -93,7 +93,7 @@ func TestAttach(t *testing.T) {
9393
Errors: []error{errors.New("read detach keys")},
9494
Output: expect.All(
9595
expect.Contains("markmark"),
96-
func(stdout string, info string, t *testing.T) {
96+
func(stdout string, t *testing.T) {
9797
assert.Assert(t, strings.Contains(helpers.Capture("inspect", "--format", "json", data.Identifier()), "\"Running\":true"))
9898
},
9999
),
@@ -125,7 +125,7 @@ func TestAttachDetachKeys(t *testing.T) {
125125
cmd.Run(&test.Expected{
126126
ExitCode: 0,
127127
Errors: []error{errors.New("read detach keys")},
128-
Output: func(stdout string, info string, t *testing.T) {
128+
Output: func(stdout string, t *testing.T) {
129129
assert.Assert(t, strings.Contains(helpers.Capture("inspect", "--format", "json", data.Identifier()), "\"Running\":true"))
130130
},
131131
})
@@ -153,7 +153,7 @@ func TestAttachDetachKeys(t *testing.T) {
153153
Errors: []error{errors.New("read detach keys")},
154154
Output: expect.All(
155155
expect.Contains("markmark"),
156-
func(stdout string, info string, t *testing.T) {
156+
func(stdout string, t *testing.T) {
157157
assert.Assert(t, strings.Contains(helpers.Capture("inspect", "--format", "json", data.Identifier()), "\"Running\":true"))
158158
},
159159
),
@@ -182,8 +182,8 @@ func TestAttachForAutoRemovedContainer(t *testing.T) {
182182
cmd.Run(&test.Expected{
183183
ExitCode: 0,
184184
Errors: []error{errors.New("read detach keys")},
185-
Output: func(stdout string, info string, t *testing.T) {
186-
assert.Assert(t, strings.Contains(helpers.Capture("inspect", "--format", "json", data.Identifier()), "\"Running\":true"), info)
185+
Output: func(stdout string, t *testing.T) {
186+
assert.Assert(t, strings.Contains(helpers.Capture("inspect", "--format", "json", data.Identifier()), "\"Running\":true"))
187187
},
188188
})
189189
}
@@ -202,7 +202,7 @@ func TestAttachForAutoRemovedContainer(t *testing.T) {
202202
ExitCode: 42,
203203
Output: expect.All(
204204
expect.Contains("markmark"),
205-
func(stdout string, info string, t *testing.T) {
205+
func(stdout string, t *testing.T) {
206206
assert.Assert(t, !strings.Contains(helpers.Capture("ps", "-a"), data.Identifier()))
207207
},
208208
),

cmd/nerdctl/container/container_commit_linux_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestKubeCommitSave(t *testing.T) {
4141
nerdtest.KubeCtlCommand(helpers, "wait", "pod", identifier, "--for=condition=ready", "--timeout=1m").Run(&test.Expected{})
4242
nerdtest.KubeCtlCommand(helpers, "exec", identifier, "--", "mkdir", "-p", "/tmp/whatever").Run(&test.Expected{})
4343
nerdtest.KubeCtlCommand(helpers, "get", "pods", identifier, "-o", "jsonpath={ .status.containerStatuses[0].containerID }").Run(&test.Expected{
44-
Output: func(stdout string, info string, t *testing.T) {
44+
Output: func(stdout string, t *testing.T) {
4545
containerID = strings.TrimPrefix(stdout, "containerd://")
4646
},
4747
})
@@ -73,7 +73,7 @@ func TestKubeCommitSave(t *testing.T) {
7373
7474
cmd = nerdtest.KubeCtlCommand(helpers, "get", "pods", tID, "-o", "jsonpath={ .status.hostIPs[0].ip }")
7575
cmd.Run(&test.Expected{
76-
Output: func(stdout string, info string, t *testing.T) {
76+
Output: func(stdout string, t *testing.T) {
7777
registryIP = stdout
7878
},
7979
})

cmd/nerdctl/container/container_create_linux_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func TestIssue2993(t *testing.T) {
231231
return &test.Expected{
232232
ExitCode: 1,
233233
Errors: []error{errors.New("is already used by ID")},
234-
Output: func(stdout string, info string, t *testing.T) {
234+
Output: func(stdout string, t *testing.T) {
235235
containersDirs, err := os.ReadDir(data.Labels().Get(containersPathKey))
236236
assert.NilError(t, err)
237237
assert.Equal(t, len(containersDirs), 1)
@@ -278,7 +278,7 @@ func TestIssue2993(t *testing.T) {
278278
return &test.Expected{
279279
ExitCode: 0,
280280
Errors: []error{},
281-
Output: func(stdout string, info string, t *testing.T) {
281+
Output: func(stdout string, t *testing.T) {
282282
containersDirs, err := os.ReadDir(data.Labels().Get(containersPathKey))
283283
assert.NilError(t, err)
284284
assert.Equal(t, len(containersDirs), 0)

cmd/nerdctl/container/container_create_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ func TestCreateHyperVContainer(t *testing.T) {
104104
helpers.Command("container", "inspect", data.Labels().Get("cID")).
105105
Run(&test.Expected{
106106
ExitCode: expect.ExitCodeNoCheck,
107-
Output: func(stdout string, info string, t *testing.T) {
107+
Output: func(stdout string, t *testing.T) {
108108
var dc []dockercompat.Container
109109
err := json.Unmarshal([]byte(stdout), &dc)
110110
if err != nil || len(dc) == 0 {
111111
return
112112
}
113-
assert.Equal(t, len(dc), 1, "Unexpectedly got multiple results\n"+info)
113+
assert.Equal(t, len(dc), 1, "Unexpectedly got multiple results\n")
114114
ran = dc[0].State.Status == "exited"
115115
},
116116
})

cmd/nerdctl/container/container_restart_linux_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ func TestRestartWithSignal(t *testing.T) {
149149
Output: expect.All(
150150
// Check that we saw SIGUSR1 inside the container
151151
expect.Contains(nerdtest.SignalCaught),
152-
func(stdout string, info string, t *testing.T) {
152+
func(stdout string, t *testing.T) {
153153
// Ensure the container was restarted
154154
nerdtest.EnsureContainerStarted(helpers, data.Identifier())
155155
// Check the new pid is different
156156
newpid := strconv.Itoa(nerdtest.InspectContainer(helpers, data.Identifier()).State.Pid)
157-
assert.Assert(helpers.T(), newpid != data.Labels().Get("oldpid"), info)
157+
assert.Assert(helpers.T(), newpid != data.Labels().Get("oldpid"))
158158
},
159159
),
160160
}

0 commit comments

Comments
 (0)