wallet: also assert no error

This commit is contained in:
vinchent 2024-09-11 11:43:34 +02:00
parent 20606d3ee5
commit 82ea599aaa

View File

@ -11,7 +11,8 @@ func TestWallet(t *testing.T) {
t.Run("withdraw", func(t *testing.T) {
wallet := Wallet{balance: Bitcoin(20)}
wallet.Withdraw(10)
err := wallet.Withdraw(10)
assertNoError(t, err)
assertBalance(t, wallet, Bitcoin(10))
})
@ -44,3 +45,11 @@ func assertError(t testing.TB, got error, want error) {
t.Errorf("got %q, want %q", got, want)
}
}
func assertNoError(t testing.TB, got error) {
t.Helper()
if got != nil {
t.Fatal("get an error but didn't want one")
}
}