Skip to content

Commit c3374b4

Browse files
authored
fix: Fix flaky logging test (#2259)
1 parent 3e7a6a6 commit c3374b4

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

pkg/output/logging/context_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package logging_test
1818

1919
import (
2020
"errors"
21+
"regexp"
2122
"testing"
2223

2324
"knative.dev/client/pkg/context"
@@ -50,9 +51,9 @@ func TestEnsureLoggerWithoutTestingT(t *testing.T) {
5051
l.Debug("test")
5152
out := printer.Outputs()
5253
got := out.Err.String()
53-
want := "0 \x1b[35mDEBUG\x1b[0m test\n"
54-
if got != want {
55-
t.Errorf("\nwant %q,\n got %q", want, got)
54+
want := regexp.MustCompile(`^\d+ \x1b\[35mDEBUG\x1b\[0m test\n$`)
55+
if !want.MatchString(got) {
56+
t.Errorf("\nwant match %q,\n got %q", want, got)
5657
}
5758
}
5859

0 commit comments

Comments
 (0)