Skip to content

Commit b363856

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

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

+339
-339
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
@@ -337,7 +337,7 @@ COPY %s /`, testFileName)
337337
},
338338
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
339339
return &test.Expected{
340-
Output: func(stdout, info string, t *testing.T) {
340+
Output: func(stdout string, t *testing.T) {
341341
// Expecting testFileName to exist inside the output target directory
342342
assert.Equal(t, data.Temp().Load(testFileName), testContent, "file content is identical")
343343
},
@@ -351,7 +351,7 @@ COPY %s /`, testFileName)
351351
},
352352
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
353353
return &test.Expected{
354-
Output: func(stdout, info string, t *testing.T) {
354+
Output: func(stdout string, t *testing.T) {
355355
assert.Equal(t, data.Temp().Load(testFileName), testContent, "file content is identical")
356356
},
357357
}
@@ -888,7 +888,7 @@ func TestBuildAttestation(t *testing.T) {
888888
},
889889
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
890890
return &test.Expected{
891-
Output: func(stdout, info string, t *testing.T) {
891+
Output: func(stdout string, t *testing.T) {
892892
data.Temp().Exists("dir-for-bom", testSBOMFileName)
893893
},
894894
}
@@ -910,7 +910,7 @@ func TestBuildAttestation(t *testing.T) {
910910
},
911911
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
912912
return &test.Expected{
913-
Output: func(stdout, info string, t *testing.T) {
913+
Output: func(stdout string, t *testing.T) {
914914
data.Temp().Exists("dir-for-prov", testProvenanceFileName)
915915
},
916916
}
@@ -933,7 +933,7 @@ func TestBuildAttestation(t *testing.T) {
933933
},
934934
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
935935
return &test.Expected{
936-
Output: func(stdout, info string, t *testing.T) {
936+
Output: func(stdout string, t *testing.T) {
937937
data.Temp().Exists("dir-for-attest", testSBOMFileName)
938938
data.Temp().Exists("dir-for-attest", testProvenanceFileName)
939939
},

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)