Skip to content

Commit

Permalink
Enable tests to run on windows
Browse files Browse the repository at this point in the history
Signed-off-by: apostasie <[email protected]>
  • Loading branch information
apostasie committed Oct 21, 2024
1 parent 71d0784 commit 124e744
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
6 changes: 2 additions & 4 deletions cmd/nerdctl/issues/main_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ func TestMain(m *testing.M) {
func TestIssue108(t *testing.T) {
testCase := nerdtest.Setup()

testCase.Require = test.Linux

testCase.SubTests = []*test.Case{
{
Description: "-it --net=host",
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
cmd := helpers.Command("run", "-it", "--rm", "--net=host", testutil.AlpineImage, "echo", "this was always working")
cmd := helpers.Command("run", "-it", "--rm", "--net=host", testutil.CommonImage, "echo", "this was always working")
cmd.WithPseudoTTY()
return cmd
},
Expand All @@ -48,7 +46,7 @@ func TestIssue108(t *testing.T) {
{
Description: "--net=host -it",
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
cmd := helpers.Command("run", "--rm", "--net=host", "-it", testutil.AlpineImage, "echo", "this was not working due to issue #108")
cmd := helpers.Command("run", "--rm", "--net=host", "-it", testutil.CommonImage, "echo", "this was not working due to issue #108")
cmd.WithPseudoTTY()
return cmd
},
Expand Down
27 changes: 23 additions & 4 deletions cmd/nerdctl/network/network_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ func TestNetworkInspect(t *testing.T) {
testIPRange = "10.24.24.0/25"
)

testCase.Setup = func(data test.Data, helpers test.Helpers) {
helpers.Ensure("network", "create", data.Identifier("basenet"))
data.Set("basenet", data.Identifier("basenet"))
}

testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
helpers.Anyhow("network", "rm", data.Identifier("basenet"))
}

testCase.SubTests = []*test.Case{
{
Description: "non existent network",
Expand Down Expand Up @@ -87,6 +96,18 @@ func TestNetworkInspect(t *testing.T) {
assert.Equal(t, dc[0].Name, "bridge")
}),
},
{
Description: "nat",
Require: test.Windows,
Command: test.Command("network", "inspect", "nat"),
Expected: test.Expects(0, nil, func(stdout string, info string, t *testing.T) {
var dc []dockercompat.Network
err := json.Unmarshal([]byte(stdout), &dc)
assert.NilError(t, err, "Unable to unmarshal output\n"+info)
assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info)
assert.Equal(t, dc[0].Name, "nat")
}),
},
{
Description: "custom",
Setup: func(data test.Data, helpers test.Helpers) {
Expand All @@ -106,9 +127,8 @@ func TestNetworkInspect(t *testing.T) {
},
{
Description: "match exact id",
Require: test.Not(test.Windows),
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
id := strings.TrimSpace(helpers.Capture("network", "inspect", "bridge", "--format", "{{ .Id }}"))
id := strings.TrimSpace(helpers.Capture("network", "inspect", data.Identifier("basenet"), "--format", "{{ .Id }}"))
return helpers.Command("network", "inspect", id)
},
Expected: test.Expects(0, nil, func(stdout string, info string, t *testing.T) {
Expand All @@ -121,9 +141,8 @@ func TestNetworkInspect(t *testing.T) {
},
{
Description: "match part of id",
Require: test.Not(test.Windows),
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
id := strings.TrimSpace(helpers.Capture("network", "inspect", "bridge", "--format", "{{ .Id }}"))
id := strings.TrimSpace(helpers.Capture("network", "inspect", data.Identifier("basenet"), "--format", "{{ .Id }}"))
return helpers.Command("network", "inspect", id[0:25])
},
Expected: test.Expects(0, nil, func(stdout string, info string, t *testing.T) {
Expand Down

0 comments on commit 124e744

Please sign in to comment.