Skip to content

Commit

Permalink
restructure testing logic
Browse files Browse the repository at this point in the history
Co-authored-by: Pranshu Srivastava <[email protected]>
  • Loading branch information
bartlettc22 and rexagod authored Oct 1, 2024
1 parent 24c2194 commit de58db2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions internal/store/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,21 @@ func TestWithEnabledResources(t *testing.T) {

// Set the enabled resources.
err := b.WithEnabledResources(test.EnabledResources)
if err != nil && !test.err.expectedResourceError {
t.Log("Did not expect error while setting resources (--resources).")
t.Errorf("Test error for Desc: %s. Got Error: %v", test.Desc, err)
if test.err.expectedResourceError {
if err == nil {
t.Log("Did not expect error while setting resources (--resources).")
t.Fatal("Test error for Desc: %s. Got Error: %v", test.Desc, err)

Check failure on line 244 in internal/store/builder_test.go

View workflow job for this annotation

GitHub Actions / ci-go-lint

printf: (*testing.common).Fatal call has possible Printf formatting directive %s (govet)

Check failure on line 244 in internal/store/builder_test.go

View workflow job for this annotation

GitHub Actions / ci-benchmark-tests

(*testing.common).Fatal call has possible Printf formatting directive %s

Check failure on line 244 in internal/store/builder_test.go

View workflow job for this annotation

GitHub Actions / ci-unit-tests

(*testing.common).Fatal call has possible Printf formatting directive %s
} else {
return
}
}
if err != nil {
t.Log("...")
t.Fatal("...", test.Desc, err)
}

// Evaluate.
if !slices.Equal(b.enabledResources, test.Wanted) && err == nil {
if !slices.Equal(b.enabledResources, test.Wanted) {
t.Log("Expected enabled resources to be equal.")
t.Errorf("Test error for Desc: %s\n Want: \n%+v\n Got: \n%#+v", test.Desc, test.Wanted, b.enabledResources)
}
Expand Down

0 comments on commit de58db2

Please sign in to comment.