Skip to content

Commit 62477fb

Browse files
authored
Merge pull request containerd#4341 from apostasie/2025-06-tigron-api-changes
[Tigron] API cleanup
2 parents 410b0f2 + 299b296 commit 62477fb

File tree

68 files changed

+535
-464
lines changed

Some content is hidden

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

68 files changed

+535
-464
lines changed

cmd/nerdctl/builder/builder_build_oci_layout_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/containerd/nerdctl/mod/tigron/expect"
2828
"github.com/containerd/nerdctl/mod/tigron/require"
2929
"github.com/containerd/nerdctl/mod/tigron/test"
30+
"github.com/containerd/nerdctl/mod/tigron/tig"
3031

3132
"github.com/containerd/nerdctl/v2/pkg/testutil"
3233
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
@@ -100,14 +101,13 @@ CMD ["echo", "test-nerdctl-build-context-oci-layout"]`
100101
},
101102
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
102103
return &test.Expected{
103-
Output: func(stdout string, info string, t *testing.T) {
104+
Output: func(stdout string, t tig.T) {
104105
assert.Assert(
105106
t,
106107
strings.Contains(
107108
helpers.Capture("run", "--rm", data.Identifier("child")),
108109
"test-nerdctl-build-context-oci-layout",
109110
),
110-
info,
111111
)
112112
},
113113
}

cmd/nerdctl/builder/builder_build_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/containerd/nerdctl/mod/tigron/expect"
3232
"github.com/containerd/nerdctl/mod/tigron/require"
3333
"github.com/containerd/nerdctl/mod/tigron/test"
34+
"github.com/containerd/nerdctl/mod/tigron/tig"
3435

3536
"github.com/containerd/nerdctl/v2/pkg/buildkitutil"
3637
"github.com/containerd/nerdctl/v2/pkg/platformutil"
@@ -342,7 +343,7 @@ COPY %s /`, testFileName)
342343
},
343344
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
344345
return &test.Expected{
345-
Output: func(stdout, info string, t *testing.T) {
346+
Output: func(stdout string, t tig.T) {
346347
// Expecting testFileName to exist inside the output target directory
347348
assert.Equal(t, data.Temp().Load(testFileName), testContent, "file content is identical")
348349
},
@@ -356,7 +357,7 @@ COPY %s /`, testFileName)
356357
},
357358
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
358359
return &test.Expected{
359-
Output: func(stdout, info string, t *testing.T) {
360+
Output: func(stdout string, t tig.T) {
360361
assert.Equal(t, data.Temp().Load(testFileName), testContent, "file content is identical")
361362
},
362363
}
@@ -894,7 +895,7 @@ func TestBuildAttestation(t *testing.T) {
894895
},
895896
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
896897
return &test.Expected{
897-
Output: func(stdout, info string, t *testing.T) {
898+
Output: func(stdout string, t tig.T) {
898899
files, err := os.ReadDir(data.Temp().Path("dir-for-bom"))
899900
assert.NilError(t, err, "failed to read directory")
900901

@@ -926,7 +927,7 @@ func TestBuildAttestation(t *testing.T) {
926927
},
927928
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
928929
return &test.Expected{
929-
Output: func(stdout, info string, t *testing.T) {
930+
Output: func(stdout string, t tig.T) {
930931
files, err := os.ReadDir(data.Temp().Path("dir-for-prov"))
931932
assert.NilError(t, err, "failed to read directory")
932933

@@ -959,7 +960,7 @@ func TestBuildAttestation(t *testing.T) {
959960
},
960961
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
961962
return &test.Expected{
962-
Output: func(stdout, info string, t *testing.T) {
963+
Output: func(stdout string, t tig.T) {
963964
// Check if any file in the directory matches the SBOM file pattern
964965
files, err := os.ReadDir(data.Temp().Path("dir-for-attest"))
965966
assert.NilError(t, err, "failed to read directory")

cmd/nerdctl/compose/compose_config_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
"github.com/containerd/nerdctl/mod/tigron/expect"
2626
"github.com/containerd/nerdctl/mod/tigron/test"
27+
"github.com/containerd/nerdctl/mod/tigron/tig"
2728

2829
"github.com/containerd/nerdctl/v2/pkg/testutil"
2930
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
@@ -113,7 +114,7 @@ services:
113114
testCase.Expected = func(data test.Data, helpers test.Helpers) *test.Expected {
114115
return &test.Expected{
115116
ExitCode: 0,
116-
Output: func(stdout, info string, t *testing.T) {
117+
Output: func(stdout string, t tig.T) {
117118
assert.Assert(t, data.Labels().Get("hash") != stdout, "hash should be different")
118119
},
119120
}

cmd/nerdctl/compose/compose_cp_linux_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
"github.com/containerd/nerdctl/mod/tigron/expect"
2626
"github.com/containerd/nerdctl/mod/tigron/test"
27+
"github.com/containerd/nerdctl/mod/tigron/tig"
2728

2829
"github.com/containerd/nerdctl/v2/pkg/testutil"
2930
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
@@ -77,7 +78,7 @@ services:
7778
},
7879
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
7980
return &test.Expected{
80-
Output: func(stdout, info string, t *testing.T) {
81+
Output: func(stdout string, t tig.T) {
8182
copied := data.Temp().Load("test-file2")
8283
assert.Equal(t, copied, testFileContent)
8384
},

cmd/nerdctl/compose/compose_create_linux_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"github.com/containerd/nerdctl/mod/tigron/expect"
2727
"github.com/containerd/nerdctl/mod/tigron/test"
28+
"github.com/containerd/nerdctl/mod/tigron/tig"
2829

2930
"github.com/containerd/nerdctl/v2/pkg/testutil"
3031
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
@@ -64,7 +65,7 @@ services:
6465
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
6566
return helpers.Command("compose", "-f", data.Labels().Get("composeYaml"), "ps", "svc0", "-a")
6667
},
67-
Expected: test.Expects(expect.ExitCodeSuccess, nil, func(stdout, info string, t *testing.T) {
68+
Expected: test.Expects(expect.ExitCodeSuccess, nil, func(stdout string, t tig.T) {
6869
assert.Assert(t,
6970
strings.Contains(stdout, "created") || strings.Contains(stdout, "Created"),
7071
"stdout should contain `created`")
@@ -121,7 +122,7 @@ services:
121122
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
122123
return helpers.Command("compose", "-f", data.Labels().Get("composeYaml"), "ps", "svc0", "-a")
123124
},
124-
Expected: test.Expects(expect.ExitCodeSuccess, nil, func(stdout, info string, t *testing.T) {
125+
Expected: test.Expects(expect.ExitCodeSuccess, nil, func(stdout string, t tig.T) {
125126
assert.Assert(t,
126127
strings.Contains(stdout, "created") || strings.Contains(stdout, "Created"),
127128
"stdout should contain `created`")
@@ -133,7 +134,7 @@ services:
133134
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
134135
return helpers.Command("compose", "-f", data.Labels().Get("composeYaml"), "ps", "svc1", "-a")
135136
},
136-
Expected: test.Expects(expect.ExitCodeSuccess, nil, func(stdout, info string, t *testing.T) {
137+
Expected: test.Expects(expect.ExitCodeSuccess, nil, func(stdout string, t tig.T) {
137138
assert.Assert(t,
138139
strings.Contains(stdout, "created") || strings.Contains(stdout, "Created"),
139140
"stdout should contain `created`")

cmd/nerdctl/compose/compose_images_linux_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ volumes:
106106
return helpers.Command("compose", "-f", data.Labels().Get("composeYaml"), "images", "--format", "json")
107107
},
108108
Expected: test.Expects(expect.ExitCodeSuccess, nil, expect.All(
109-
expect.JSON([]composeContainerPrintable{}, func(printables []composeContainerPrintable, s string, t tig.T) {
109+
expect.JSON([]composeContainerPrintable{}, func(printables []composeContainerPrintable, t tig.T) {
110110
assert.Equal(t, len(printables), 2)
111111
}),
112112
expect.Contains(`"ContainerName":"wordpress"`, `"ContainerName":"db"`),
@@ -118,7 +118,7 @@ volumes:
118118
return helpers.Command("compose", "-f", data.Labels().Get("composeYaml"), "images", "--format", "json", "wordpress")
119119
},
120120
Expected: test.Expects(expect.ExitCodeSuccess, nil, expect.All(
121-
expect.JSON([]composeContainerPrintable{}, func(printables []composeContainerPrintable, s string, t tig.T) {
121+
expect.JSON([]composeContainerPrintable{}, func(printables []composeContainerPrintable, t tig.T) {
122122
assert.Equal(t, len(printables), 1)
123123
}),
124124
expect.Contains(`"ContainerName":"wordpress"`),

cmd/nerdctl/compose/compose_rm_linux_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/containerd/nerdctl/mod/tigron/expect"
2525
"github.com/containerd/nerdctl/mod/tigron/test"
26+
"github.com/containerd/nerdctl/mod/tigron/tig"
2627

2728
"github.com/containerd/nerdctl/v2/pkg/testutil"
2829
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
@@ -78,12 +79,12 @@ volumes:
7879
},
7980
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
8081
return &test.Expected{
81-
Output: func(stdout, info string, t *testing.T) {
82+
Output: func(stdout string, t tig.T) {
8283
wp := helpers.Capture("compose", "-f", data.Labels().Get("yamlPath"), "ps", "wordpress")
8384
db := helpers.Capture("compose", "-f", data.Labels().Get("yamlPath"), "ps", "db")
8485
comp := expect.Match(regexp.MustCompile("Up|running"))
85-
comp(wp, "", t)
86-
comp(db, "", t)
86+
comp(wp, t)
87+
comp(db, t)
8788
},
8889
}
8990
},
@@ -97,11 +98,11 @@ volumes:
9798
},
9899
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
99100
return &test.Expected{
100-
Output: func(stdout, info string, t *testing.T) {
101+
Output: func(stdout string, t tig.T) {
101102
wp := helpers.Capture("compose", "-f", data.Labels().Get("yamlPath"), "ps", "wordpress")
102103
db := helpers.Capture("compose", "-f", data.Labels().Get("yamlPath"), "ps", "db")
103-
expect.DoesNotContain("wordpress")(wp, "", t)
104-
expect.Match(regexp.MustCompile("Up|running"))(db, "", t)
104+
expect.DoesNotContain("wordpress")(wp, t)
105+
expect.Match(regexp.MustCompile("Up|running"))(db, t)
105106
},
106107
}
107108
},
@@ -114,9 +115,9 @@ volumes:
114115
},
115116
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
116117
return &test.Expected{
117-
Output: func(stdout, info string, t *testing.T) {
118+
Output: func(stdout string, t tig.T) {
118119
db := helpers.Capture("compose", "-f", data.Labels().Get("yamlPath"), "ps", "db")
119-
expect.DoesNotContain("db")(db, "", t)
120+
expect.DoesNotContain("db")(db, t)
120121
},
121122
}
122123
},

cmd/nerdctl/compose/compose_start_linux_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/containerd/nerdctl/mod/tigron/expect"
2525
"github.com/containerd/nerdctl/mod/tigron/test"
26+
"github.com/containerd/nerdctl/mod/tigron/tig"
2627

2728
"github.com/containerd/nerdctl/v2/pkg/testutil"
2829
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
@@ -61,12 +62,12 @@ services:
6162
return &test.Expected{
6263
ExitCode: 0,
6364
Errors: nil,
64-
Output: func(stdout, info string, t *testing.T) {
65+
Output: func(stdout string, t tig.T) {
6566
svc0 := helpers.Capture("compose", "-f", data.Temp().Path("compose.yaml"), "ps", "svc0")
6667
svc1 := helpers.Capture("compose", "-f", data.Temp().Path("compose.yaml"), "ps", "svc1")
6768
comp := expect.Match(regexp.MustCompile("Up|running"))
68-
comp(svc0, "", t)
69-
comp(svc1, "", t)
69+
comp(svc0, t)
70+
comp(svc1, t)
7071
},
7172
}
7273
}

cmd/nerdctl/compose/compose_up_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"github.com/containerd/nerdctl/mod/tigron/require"
2727
"github.com/containerd/nerdctl/mod/tigron/test"
28+
"github.com/containerd/nerdctl/mod/tigron/tig"
2829

2930
"github.com/containerd/nerdctl/v2/pkg/testutil"
3031
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
@@ -94,7 +95,7 @@ services:
9495
return &test.Expected{
9596
ExitCode: 0,
9697
Errors: nil,
97-
Output: func(stdout, info string, t *testing.T) {
98+
Output: func(stdout string, t tig.T) {
9899
assert.Equal(t, data.Temp().Load("foo", "test"), "hi\n")
99100
},
100101
}

cmd/nerdctl/container/container_attach_linux_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
"github.com/containerd/nerdctl/mod/tigron/expect"
3030
"github.com/containerd/nerdctl/mod/tigron/test"
31+
"github.com/containerd/nerdctl/mod/tigron/tig"
3132

3233
"github.com/containerd/nerdctl/v2/pkg/testutil"
3334
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
@@ -64,7 +65,7 @@ func TestAttach(t *testing.T) {
6465
cmd.Run(&test.Expected{
6566
ExitCode: 0,
6667
Errors: []error{errors.New("read detach keys")},
67-
Output: func(stdout string, info string, t *testing.T) {
68+
Output: func(stdout string, t tig.T) {
6869
assert.Assert(t, strings.Contains(helpers.Capture("inspect", "--format", "json", data.Identifier()), "\"Running\":true"))
6970
},
7071
})
@@ -93,7 +94,7 @@ func TestAttach(t *testing.T) {
9394
Errors: []error{errors.New("read detach keys")},
9495
Output: expect.All(
9596
expect.Contains("markmark"),
96-
func(stdout string, info string, t *testing.T) {
97+
func(stdout string, t tig.T) {
9798
assert.Assert(t, strings.Contains(helpers.Capture("inspect", "--format", "json", data.Identifier()), "\"Running\":true"))
9899
},
99100
),
@@ -125,7 +126,7 @@ func TestAttachDetachKeys(t *testing.T) {
125126
cmd.Run(&test.Expected{
126127
ExitCode: 0,
127128
Errors: []error{errors.New("read detach keys")},
128-
Output: func(stdout string, info string, t *testing.T) {
129+
Output: func(stdout string, t tig.T) {
129130
assert.Assert(t, strings.Contains(helpers.Capture("inspect", "--format", "json", data.Identifier()), "\"Running\":true"))
130131
},
131132
})
@@ -153,7 +154,7 @@ func TestAttachDetachKeys(t *testing.T) {
153154
Errors: []error{errors.New("read detach keys")},
154155
Output: expect.All(
155156
expect.Contains("markmark"),
156-
func(stdout string, info string, t *testing.T) {
157+
func(stdout string, t tig.T) {
157158
assert.Assert(t, strings.Contains(helpers.Capture("inspect", "--format", "json", data.Identifier()), "\"Running\":true"))
158159
},
159160
),
@@ -182,8 +183,8 @@ func TestAttachForAutoRemovedContainer(t *testing.T) {
182183
cmd.Run(&test.Expected{
183184
ExitCode: 0,
184185
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)
186+
Output: func(stdout string, t tig.T) {
187+
assert.Assert(t, strings.Contains(helpers.Capture("inspect", "--format", "json", data.Identifier()), "\"Running\":true"))
187188
},
188189
})
189190
}
@@ -202,7 +203,7 @@ func TestAttachForAutoRemovedContainer(t *testing.T) {
202203
ExitCode: 42,
203204
Output: expect.All(
204205
expect.Contains("markmark"),
205-
func(stdout string, info string, t *testing.T) {
206+
func(stdout string, t tig.T) {
206207
assert.Assert(t, !strings.Contains(helpers.Capture("ps", "-a"), data.Identifier()))
207208
},
208209
),
@@ -226,7 +227,7 @@ func TestAttachNoStdin(t *testing.T) {
226227
cmd.Feed(bytes.NewReader([]byte{16, 17})) // Ctrl-p, Ctrl-q to detach (https://en.wikipedia.org/wiki/C0_and_C1_control_codes)
227228
cmd.Run(&test.Expected{
228229
ExitCode: 0,
229-
Output: func(stdout string, info string, t *testing.T) {
230+
Output: func(stdout string, t tig.T) {
230231
assert.Assert(t, strings.Contains(helpers.Capture("inspect", "--format", "{{.State.Running}}", data.Identifier()), "true"))
231232
},
232233
})
@@ -243,7 +244,7 @@ func TestAttachNoStdin(t *testing.T) {
243244
testCase.Expected = func(data test.Data, helpers test.Helpers) *test.Expected {
244245
return &test.Expected{
245246
ExitCode: 0, // Since it's a normal exit and not detach.
246-
Output: func(stdout string, info string, t *testing.T) {
247+
Output: func(stdout string, t tig.T) {
247248
logs := helpers.Capture("logs", data.Identifier())
248249
assert.Assert(t, !strings.Contains(logs, "should-not-appear"))
249250
},

0 commit comments

Comments
 (0)