@@ -25,6 +25,8 @@ import (
25
25
"gotest.tools/v3/assert"
26
26
27
27
"github.com/containerd/nerdctl/v2/pkg/testutil"
28
+ "github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
29
+ "github.com/containerd/nerdctl/v2/pkg/testutil/test"
28
30
)
29
31
30
32
func TestRunHostProcessContainer (t * testing.T ) {
@@ -119,16 +121,27 @@ func TestRunProcessContainerWithDevice(t *testing.T) {
119
121
}
120
122
121
123
func TestRunWithTtyAndDetached (t * testing.T ) {
122
- base := testutil .NewBase (t )
123
- imageName := testutil .CommonImage
124
- withTtyContainerName := "with-terminal-" + testutil .Identifier (t )
124
+ testCase := nerdtest .Setup ()
125
+
126
+ // This test is currently disabled, as it is failing most of the time.
127
+ testCase .Require = nerdtest .NerdctlNeedsFixing ("https://github.com/containerd/nerdctl/issues/3437" )
128
+
129
+ testCase .Setup = func (data test.Data , helpers test.Helpers ) {
130
+ // with -t, success, the container should run with tty support.
131
+ helpers .Ensure ("run" , "-d" , "-t" , "--name" , data .Identifier ("with-terminal" ), testutil .CommonImage , "cmd" , "/c" , "echo" , "Hello, World with TTY!" )
132
+ }
133
+
134
+ testCase .Cleanup = func (data test.Data , helpers test.Helpers ) {
135
+ helpers .Anyhow ("container" , "rm" , "-f" , data .Identifier ("with-terminal" ))
136
+ }
137
+
138
+ testCase .Command = func (data test.Data , helpers test.Helpers ) test.TestableCommand {
139
+ withTtyContainer := nerdtest .InspectContainer (helpers , data .Identifier ("with-terminal" ))
140
+ assert .Equal (helpers .T (), 0 , withTtyContainer .State .ExitCode )
141
+ return helpers .Command ("logs" , data .Identifier ("with-terminal" ))
142
+ }
125
143
126
- // with -t, success, the container should run with tty support.
127
- base .Cmd ("run" , "-d" , "-t" , "--name" , withTtyContainerName , imageName , "cmd" , "/c" , "echo" , "Hello, World with TTY!" ).AssertOK ()
128
- defer base .Cmd ("container" , "rm" , "-f" , withTtyContainerName ).AssertOK ()
144
+ testCase .Expected = test .Expects (0 , nil , test .Contains ("Hello, World with TTY!" ))
129
145
130
- // Check logs for successful command execution (with TTY specific behavior if any)
131
- base .Cmd ("logs" , withTtyContainerName ).AssertOutContains ("Hello, World with TTY!" )
132
- withTtyContainer := base .InspectContainer (withTtyContainerName )
133
- assert .Equal (base .T , 0 , withTtyContainer .State .ExitCode )
146
+ testCase .Run (t )
134
147
}
0 commit comments