@@ -41,6 +41,7 @@ import (
41
41
"github.com/containerd/nerdctl/v2/pkg/testutil"
42
42
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
43
43
"github.com/containerd/nerdctl/v2/pkg/testutil/nettestutil"
44
+ "github.com/containerd/nerdctl/v2/pkg/testutil/test"
44
45
)
45
46
46
47
func extractHostPort (portMapping string , port string ) (string , error ) {
@@ -350,15 +351,29 @@ func TestRunPort(t *testing.T) {
350
351
}
351
352
352
353
func TestRunWithInvalidPortThenCleanUp (t * testing.T ) {
354
+ testCase := nerdtest .Setup ()
353
355
// docker does not set label restriction to 4096 bytes
354
- testutil .DockerIncompatible (t )
355
- t .Parallel ()
356
- base := testutil .NewBase (t )
357
- containerName := testutil .Identifier (t )
358
- defer base .Cmd ("rm" , "-f" , containerName ).Run ()
359
- base .Cmd ("run" , "--rm" , "--name" , containerName , "-p" , "22200-22299:22200-22299" , testutil .CommonImage ).AssertFail ()
360
- base .Cmd ("run" , "--rm" , "--name" , containerName , "-p" , "22200-22299:22200-22299" , testutil .CommonImage ).AssertCombinedOutContains (errdefs .ErrInvalidArgument .Error ())
361
- base .Cmd ("run" , "--rm" , "--name" , containerName , testutil .CommonImage ).AssertOK ()
356
+ testCase .Require = test .Not (nerdtest .Docker )
357
+
358
+ testCase .SubTests = []* test.Case {
359
+ {
360
+ Description : "Run a container with invalid ports, and then clean up." ,
361
+ Cleanup : func (data test.Data , helpers test.Helpers ) {
362
+ helpers .Anyhow ("rm" , "--data-root" , data .TempDir (), "-f" , data .Identifier ())
363
+ },
364
+ Command : func (data test.Data , helpers test.Helpers ) test.TestableCommand {
365
+ return helpers .Command ("run" , "--data-root" , data .TempDir (), "--rm" , "--name" , data .Identifier (), "-p" , "22200-22299:22200-22299" , testutil .CommonImage )
366
+ },
367
+ Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
368
+ return & test.Expected {
369
+ ExitCode : 1 ,
370
+ Errors : []error {errdefs .ErrInvalidArgument },
371
+ }
372
+ },
373
+ },
374
+ }
375
+
376
+ testCase .Run (t )
362
377
}
363
378
364
379
func TestRunContainerWithStaticIP (t * testing.T ) {
0 commit comments