Skip to content

Commit 41a5c9b

Browse files
committed
refactor: simplify no-wants Err check
1 parent ebae84e commit 41a5c9b

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Be doesn't fail the test when an assertion fails, so you can see all the errors
143143

144144
The parameter order is (got, want), not (want, got). It just feels more natural — like saying "account balance is 100 coins" instead of "100 coins is the account balance".
145145

146-
Be has ≈100 lines of code (+450 lines for tests). For comparison, `is` has ≈250 loc (+250 lines for tests).
146+
Be has ≈150 lines of code (+500 lines for tests). For comparison, `is` has ≈250 loc (+250 lines for tests).
147147

148148
## Contributing
149149

be.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,10 @@ func Err(tb testing.TB, got error, wants ...any) {
7070

7171
// If no wants are given, we expect got to be a non-nil error.
7272
if len(wants) == 0 {
73-
if got != nil {
74-
// got is a non-nil error, nothing to report.
75-
return
76-
} else {
77-
// Expected an error, but got nil.
73+
if got == nil {
7874
tb.Error("want error, got <nil>")
79-
return
8075
}
76+
return
8177
}
8278

8379
// Special case: there's only one want, it's nil, but got is not nil.

0 commit comments

Comments
 (0)