Skip to content

Commit 3bb441d

Browse files
committed
Enable tests to run on windows
Signed-off-by: apostasie <[email protected]>
1 parent 71d0784 commit 3bb441d

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

cmd/nerdctl/issues/main_linux_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@ func TestMain(m *testing.M) {
3333
func TestIssue108(t *testing.T) {
3434
testCase := nerdtest.Setup()
3535

36-
testCase.Require = test.Linux
37-
3836
testCase.SubTests = []*test.Case{
3937
{
4038
Description: "-it --net=host",
4139
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
42-
cmd := helpers.Command("run", "-it", "--rm", "--net=host", testutil.AlpineImage, "echo", "this was always working")
40+
cmd := helpers.Command("run", "-it", "--rm", "--net=host", testutil.CommonImage, "echo", "this was always working")
4341
cmd.WithPseudoTTY()
4442
return cmd
4543
},
@@ -48,7 +46,7 @@ func TestIssue108(t *testing.T) {
4846
{
4947
Description: "--net=host -it",
5048
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
51-
cmd := helpers.Command("run", "--rm", "--net=host", "-it", testutil.AlpineImage, "echo", "this was not working due to issue #108")
49+
cmd := helpers.Command("run", "--rm", "--net=host", "-it", testutil.CommonImage, "echo", "this was not working due to issue #108")
5250
cmd.WithPseudoTTY()
5351
return cmd
5452
},

cmd/nerdctl/network/network_inspect_test.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ func TestNetworkInspect(t *testing.T) {
3838
testIPRange = "10.24.24.0/25"
3939
)
4040

41+
testCase.Setup = func(data test.Data, helpers test.Helpers) {
42+
helpers.Ensure("network", "create", data.Identifier("basenet"))
43+
data.Set("basenet", data.Identifier("basenet"))
44+
}
45+
46+
testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
47+
helpers.Anyhow("network", "rm", data.Identifier("basenet"))
48+
}
49+
4150
testCase.SubTests = []*test.Case{
4251
{
4352
Description: "non existent network",
@@ -87,6 +96,18 @@ func TestNetworkInspect(t *testing.T) {
8796
assert.Equal(t, dc[0].Name, "bridge")
8897
}),
8998
},
99+
{
100+
Description: "nat",
101+
Require: test.Windows,
102+
Command: test.Command("network", "inspect", "nat"),
103+
Expected: test.Expects(0, nil, func(stdout string, info string, t *testing.T) {
104+
var dc []dockercompat.Network
105+
err := json.Unmarshal([]byte(stdout), &dc)
106+
assert.NilError(t, err, "Unable to unmarshal output\n"+info)
107+
assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info)
108+
assert.Equal(t, dc[0].Name, "nat")
109+
}),
110+
},
90111
{
91112
Description: "custom",
92113
Setup: func(data test.Data, helpers test.Helpers) {
@@ -106,9 +127,8 @@ func TestNetworkInspect(t *testing.T) {
106127
},
107128
{
108129
Description: "match exact id",
109-
Require: test.Not(test.Windows),
110130
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
111-
id := strings.TrimSpace(helpers.Capture("network", "inspect", "bridge", "--format", "{{ .Id }}"))
131+
id := strings.TrimSpace(helpers.Capture("network", "inspect", data.Get("basenet"), "--format", "{{ .Id }}"))
112132
return helpers.Command("network", "inspect", id)
113133
},
114134
Expected: test.Expects(0, nil, func(stdout string, info string, t *testing.T) {
@@ -121,9 +141,8 @@ func TestNetworkInspect(t *testing.T) {
121141
},
122142
{
123143
Description: "match part of id",
124-
Require: test.Not(test.Windows),
125144
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
126-
id := strings.TrimSpace(helpers.Capture("network", "inspect", "bridge", "--format", "{{ .Id }}"))
145+
id := strings.TrimSpace(helpers.Capture("network", "inspect", data.Get("basenet"), "--format", "{{ .Id }}"))
127146
return helpers.Command("network", "inspect", id[0:25])
128147
},
129148
Expected: test.Expects(0, nil, func(stdout string, info string, t *testing.T) {

0 commit comments

Comments
 (0)