Skip to content

Commit

Permalink
Fixing the fluke test
Browse files Browse the repository at this point in the history
by relaxing the stderr checks
  • Loading branch information
cardil committed Jul 10, 2024
1 parent bc2fe4e commit f103e9a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 39 deletions.
8 changes: 2 additions & 6 deletions test/unit/codegen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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() {
Expand Down
41 changes: 8 additions & 33 deletions test/unit/sharedlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -103,31 +80,29 @@ 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",
Padding: "1 3",
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",
Padding: "0 1",
Foreground: "44",
BorderForeground: "44",
})
return o.check(makeBanner(styles, msg))
return contains(makeBanner(styles, msg))
}

func libglossDefaults(styles style.StylesNotHidden) style.StylesNotHidden {
Expand Down

0 comments on commit f103e9a

Please sign in to comment.