restructure testing logic

Co-authored-by: Pranshu Srivastava <prasriva@redhat.com>
This commit is contained in:
Chris Bartlett 2024-10-01 13:35:32 -06:00 committed by GitHub
parent 24c2194e7e
commit de58db2ed4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 4 deletions

View File

@ -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)
} 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)
}