Skip to content

Commit 57a1592

Browse files
committed
pkg/compose: fix TestRunHook_ConsoleSize on macOS
containerd/console is broken on macOS, and panics; use creack/pty instead for this test. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent e742d09 commit 57a1592

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

pkg/compose/hook_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"testing"
2323

2424
"github.com/compose-spec/compose-go/v2/types"
25-
"github.com/containerd/console"
25+
"github.com/creack/pty"
2626
"github.com/docker/cli/cli/streams"
2727
"github.com/moby/moby/api/types/container"
2828
"github.com/moby/moby/client"
@@ -67,15 +67,13 @@ func TestRunHook_ConsoleSize(t *testing.T) {
6767

6868
// Create a PTY so GetTtySize() returns real non-zero dimensions,
6969
// simulating an interactive terminal session.
70-
pty, slavePath, err := console.NewPty()
70+
masterFile, slaveFile, err := pty.Open()
7171
assert.NilError(t, err)
72-
defer pty.Close() //nolint:errcheck
73-
assert.NilError(t, pty.Resize(console.WinSize{Height: 24, Width: 80}))
74-
75-
slaveFile, err := os.OpenFile(slavePath, os.O_RDWR, 0)
76-
assert.NilError(t, err)
77-
defer slaveFile.Close() //nolint:errcheck
78-
72+
t.Cleanup(func() {
73+
_ = masterFile.Close()
74+
_ = slaveFile.Close()
75+
})
76+
assert.NilError(t, pty.Setsize(masterFile, &pty.Winsize{Rows: 24, Cols: 80}))
7977
mockCli.EXPECT().Out().Return(streams.NewOut(slaveFile)).AnyTimes()
8078

8179
service := types.ServiceConfig{
@@ -114,3 +112,6 @@ func TestRunHook_ConsoleSize(t *testing.T) {
114112
})
115113
}
116114
}
115+
116+
func TestConsole(t *testing.T) {
117+
}

0 commit comments

Comments
 (0)