From f103e9a997ba82e3f96c1e4090e7cedf4c46358c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20Suszy=C5=84ski?= Date: Wed, 10 Jul 2024 18:49:57 +0200 Subject: [PATCH] Fixing the fluke test by relaxing the stderr checks --- test/unit/codegen_test.go | 8 ++------ test/unit/sharedlib_test.go | 41 ++++++++----------------------------- 2 files changed, 10 insertions(+), 39 deletions(-) diff --git a/test/unit/codegen_test.go b/test/unit/codegen_test.go index 541288c4..c78aebb7 100644 --- a/test/unit/codegen_test.go +++ b/test/unit/codegen_test.go @@ -39,11 +39,7 @@ Deepcopy generation complete --- Cleaning up generated code `, ), - stderr: warned( - "Failed to determine the knative.dev/pkg package", - func(o *headerOpts) { - o.equals = true - }), + stderr: warned("Failed to determine the knative.dev/pkg package"), }} for i := range tcs { tc := tcs[i] @@ -63,7 +59,7 @@ func mockDeepcopyGen(t TestingT, opts ...deepcopyGenOpt) scriptlet { opt(&d) } execPermission := os.FileMode(0o755) - var slet scriptlet = instructions() + slet := instructions() gobin := path.Join(currentGopath(), "bin") deepcopyGenPath := path.Join(gobin, "deepcopy-gen") if !isCheckoutOntoGopath() { diff --git a/test/unit/sharedlib_test.go b/test/unit/sharedlib_test.go index 0edd36bf..4ec4b25a 100644 --- a/test/unit/sharedlib_test.go +++ b/test/unit/sharedlib_test.go @@ -58,29 +58,7 @@ func ensureGoModDownloaded() { } } -type headerOpts struct { - equals bool -} - -func (o headerOpts) check(s string) check { - if o.equals { - return equal(s)[0] - } - return contains(s) -} - -type headerOpt func(*headerOpts) - -func compileHeaderOpts(opts []headerOpt) headerOpts { - o := headerOpts{} - for _, opt := range opts { - opt(&o) - } - return o -} - -func aborted(msg string, opts ...headerOpt) []check { - o := compileHeaderOpts(opts) +func aborted(msg string) []check { fmsg := fmt.Sprintf("ERROR: %s", msg) styles := libglossDefaults(style.StylesNotHidden{ Border: "double", @@ -89,11 +67,10 @@ func aborted(msg string, opts ...headerOpt) []check { Foreground: "#D00", BorderForeground: "#D00", }) - return []check{o.check(makeBanner(styles, fmsg))} + return []check{contains(makeBanner(styles, fmsg))} } -func warned(msg string, opts ...headerOpt) []check { - o := compileHeaderOpts(opts) +func warned(msg string) []check { fmsg := fmt.Sprintf("WARN: %s", msg) styles := libglossDefaults(style.StylesNotHidden{ Border: "rounded", @@ -103,11 +80,10 @@ func warned(msg string, opts ...headerOpt) []check { BorderForeground: "#DD0", }) - return []check{o.check(makeBanner(styles, fmsg))} + return []check{contains(makeBanner(styles, fmsg))} } -func header(msg string, opts ...headerOpt) check { - o := compileHeaderOpts(opts) +func header(msg string) check { styles := libglossDefaults(style.StylesNotHidden{ Border: "double", Align: "center", @@ -115,11 +91,10 @@ func header(msg string, opts ...headerOpt) check { Foreground: "45", BorderForeground: "45", }) - return o.check(makeBanner(styles, msg)) + return contains(makeBanner(styles, msg)) } -func subheader(msg string, opts ...headerOpt) check { - o := compileHeaderOpts(opts) +func subheader(msg string) check { styles := libglossDefaults(style.StylesNotHidden{ Border: "rounded", Align: "center", @@ -127,7 +102,7 @@ func subheader(msg string, opts ...headerOpt) check { Foreground: "44", BorderForeground: "44", }) - return o.check(makeBanner(styles, msg)) + return contains(makeBanner(styles, msg)) } func libglossDefaults(styles style.StylesNotHidden) style.StylesNotHidden {