Skip to content

Commit db57f37

Browse files
committed
Rewrite TestLogsWithoutNewlineOrEOF
Signed-off-by: apostasie <[email protected]>
1 parent 28d77b6 commit db57f37

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

cmd/nerdctl/container/container_logs_test.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,26 @@ func TestLogsWithRunningContainer(t *testing.T) {
194194
}
195195

196196
func TestLogsWithoutNewlineOrEOF(t *testing.T) {
197-
if runtime.GOOS != "linux" {
198-
t.Skip("FIXME: test does not work on Windows yet because containerd doesn't send an exit event appropriately after task exit on Windows")
197+
testCase := nerdtest.Setup()
198+
// FIXME: test does not work on Windows yet because containerd doesn't send an exit event appropriately after task exit on Windows")
199+
// FIXME: nerdctl behavior does not match docker - test disabled for nerdctl until we fix
200+
testCase.Require = require.All(
201+
require.Linux,
202+
nerdtest.NerdctlNeedsFixing("https://github.com/containerd/nerdctl/issues/4201"),
203+
)
204+
testCase.Setup = func(data test.Data, helpers test.Helpers) {
205+
helpers.Ensure("run", "-d", "--name", data.Identifier(), testutil.CommonImage, "printf", "'Hello World!\nThere is no newline'")
199206
}
200-
t.Parallel()
201-
base := testutil.NewBase(t)
202-
containerName := testutil.Identifier(t)
203-
defer base.Cmd("rm", "-f", containerName).Run()
204-
expected := []string{"Hello World!", "There is no newline"}
205-
base.Cmd("run", "-d", "--name", containerName, testutil.CommonImage,
206-
"printf", "'Hello World!\nThere is no newline'").AssertOK()
207-
time.Sleep(3 * time.Second)
208-
base.Cmd("logs", "-f", containerName).AssertOutContainsAll(expected...)
207+
testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
208+
helpers.Anyhow("rm", "-f", data.Identifier())
209+
}
210+
testCase.Command = func(data test.Data, helpers test.Helpers) test.TestableCommand {
211+
// FIXME: arbitrary timeouts are by nature a problem.
212+
time.Sleep(5 * time.Second)
213+
return helpers.Command("logs", "-f", data.Identifier())
214+
}
215+
testCase.Expected = test.Expects(0, nil, expect.Equals("'Hello World!\nThere is no newline'"))
216+
testCase.Run(t)
209217
}
210218

211219
func TestLogsAfterRestartingContainer(t *testing.T) {

0 commit comments

Comments
 (0)