Skip to content

Commit

Permalink
Fix failing unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Carolyn Van Slyck <[email protected]>
  • Loading branch information
carolynvs committed Mar 16, 2022
1 parent 8a0bcdc commit 844b521
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions pkg/porter/packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ func TestSearchOptions_Validate_PackageName(t *testing.T) {

func TestPorter_SearchPackages_Mixins(t *testing.T) {
testcases := []struct {
name string
mixin string
format printer.Format
wantOutput string
wantErr string
name string
mixin string
format printer.Format
wantOutput string
wantNonEmptyOutput bool
wantErr string
}{{
name: "no name provided",
mixin: "",
format: printer.FormatJson,
wantOutput: "testdata/packages/search-no-query.txt",
name: "no name provided",
mixin: "",
format: printer.FormatJson,
wantNonEmptyOutput: true,
}, {
name: "mixin name single match",
mixin: "az",
Expand Down Expand Up @@ -97,7 +98,13 @@ func TestPorter_SearchPackages_Mixins(t *testing.T) {
} else {
require.NoError(t, err)
gotOutput := p.TestConfig.TestContext.GetOutput()
test.CompareGoldenFile(t, tc.wantOutput, gotOutput)

// Only check that the output isn't empty, but don't try to match the exact contents because it changes
if tc.wantNonEmptyOutput {
assert.NotEmpty(t, gotOutput, "expected the output to not be empty")
} else {
test.CompareGoldenFile(t, tc.wantOutput, gotOutput)
}
}
})
}
Expand Down

0 comments on commit 844b521

Please sign in to comment.