Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ut): fix flaky console tests #1544

Merged
merged 3 commits into from
Nov 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions cmd/oras/internal/display/status/console/console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ func givenTestConsole(t *testing.T) (c Console, pty containerd.Console, tty *os.
if err != nil {
t.Fatal(err)
}

c = &console{
Console: pty,
c, err = NewConsole(tty)
if err != nil {
t.Fatal(err)
}
return c, pty, tty
return
}

func validateSize(t *testing.T, gotWidth, gotHeight, wantWidth, wantHeight int) {
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestConsole_NewRow(t *testing.T) {

c.NewRow()

err := testutils.MatchPty(pty, tty, "^[8\r\n^[7")
err := testutils.MatchPty(pty, tty, "\x1b8\r\n\x1b7")
TerryHowe marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
t.Fatalf("NewRow output error: %v", err)
}
Expand All @@ -107,7 +107,7 @@ func TestConsole_OutputTo(t *testing.T) {

c.OutputTo(1, "test string")

err := testutils.MatchPty(pty, tty, "^[8^[[1Ftest string^[[0m\r\n^[[0K")
err := testutils.MatchPty(pty, tty, "\x1b8\x1b[1Ftest string\x1b[0m\r\n\x1b[0K")
if err != nil {
t.Fatalf("OutputTo output error: %v", err)
}
Expand All @@ -118,7 +118,7 @@ func TestConsole_Restore(t *testing.T) {

c.Restore()

err := testutils.MatchPty(pty, tty, "^[8^[[0G^[[2K^[[?25h")
err := testutils.MatchPty(pty, tty, "\x1b8\x1b[0G\x1b[2K\x1b[?25h")
if err != nil {
t.Fatalf("Restore output error: %v", err)
}
Expand All @@ -129,7 +129,7 @@ func TestConsole_Save(t *testing.T) {

c.Save()

err := testutils.MatchPty(pty, tty, "^[[?25l^[7^[[0m")
err := testutils.MatchPty(pty, tty, "\x1b[?25l\x1b7\x1b[0m")
if err != nil {
t.Fatalf("Save output error: %v", err)
}
Expand Down
Loading