@@ -37,6 +37,7 @@ import (
37
37
"github.com/containerd/containerd/v2/defaults"
38
38
"github.com/containerd/containerd/v2/pkg/netns"
39
39
"github.com/containerd/errdefs"
40
+ "github.com/containerd/nerdctl/mod/tigron/expect"
40
41
"github.com/containerd/nerdctl/mod/tigron/require"
41
42
"github.com/containerd/nerdctl/mod/tigron/test"
42
43
@@ -924,23 +925,19 @@ func TestNoneNetworkHostName(t *testing.T) {
924
925
testCase := &test.Case{
925
926
Require: require.Not(require.Windows),
926
927
Setup: func(data test.Data, helpers test.Helpers) {
927
- data.Set("containerName1", data.Identifier())
928
+ output := helpers.Capture("run", "-d", "--name", data.Identifier(), "--network", "none", testutil.NginxAlpineImage)
929
+ assert.Assert(helpers.T(), len(output) > 12, output)
930
+ data.Set("hostname", output[:12])
928
931
},
929
932
Cleanup: func(data test.Data, helpers test.Helpers) {
930
933
helpers.Anyhow("rm", "-f", data.Identifier())
931
934
},
932
935
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
933
- return helpers.Command("run ", "-d", "--name", data.Identifier(), "--network ", "none", testutil.NginxAlpineImage )
936
+ return helpers.Command("exec ", data.Identifier(), "cat ", "/etc/hostname" )
934
937
},
935
938
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
936
939
return &test.Expected{
937
- Output: func(stdout string, info string, t *testing.T) {
938
- hostname := stdout
939
- if len(hostname) > 12 {
940
- hostname = hostname[:12]
941
- }
942
- assert.Assert(t, strings.Compare(strings.TrimSpace(helpers.Capture("exec", data.Identifier(), "cat", "/etc/hostname")), hostname) == 0, info)
943
- },
940
+ Output: expect.Equals(data.Get("hostname") + "\n"),
944
941
}
945
942
},
946
943
}
0 commit comments