Skip to content

Commit

Permalink
refact: ShouldNotExist is equal to ShouldNotBeNil (ovh#805)
Browse files Browse the repository at this point in the history
no need to compare zero nor blank value

close ovh#732

Signed-off-by: Yvonnick Esnault <[email protected]>

---------

Signed-off-by: Yvonnick Esnault <[email protected]>
  • Loading branch information
yesnault authored Aug 14, 2024
1 parent dce5a19 commit c90aa1f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions assertions/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,9 @@ func ShouldBeNil(actual interface{}, expected ...interface{}) error {
return fmt.Errorf("expected: Nil but is wasn't")
}

// ShouldNotExist receives a single parameter and ensures that it is nil, blank or zero value
// ShouldNotExist receives a single parameter and ensures that it is nil
func ShouldNotExist(actual interface{}, expected ...interface{}) error {
if ShouldBeNil(actual) != nil ||
ShouldBeBlank(actual) != nil ||
ShouldBeZeroValue(actual) != nil {
if ShouldBeNil(actual) != nil {
return fmt.Errorf("expected not exist but it was")
}
return nil
Expand Down

0 comments on commit c90aa1f

Please sign in to comment.