diff --git a/wallet/wallet_test.go b/wallet/wallet_test.go index cc66fa6..a0f7f89 100644 --- a/wallet/wallet_test.go +++ b/wallet/wallet_test.go @@ -8,15 +8,18 @@ func TestWallet(t *testing.T) { got := wallet.Balance() if got != want { - t.Errorf("got %q want %q", got, want) + t.Errorf("got %q, want %q", got, want) } } - assertError := func(t testing.TB, err error) { + assertError := func(t testing.TB, got error, want string) { t.Helper() - if err == nil { - t.Error("wanted an error but didn't get one") + if got == nil { + t.Fatal("didn't get an error but wanted one") + } + if got.Error() != want { + t.Errorf("got %q, want %q", got, want) } } @@ -37,7 +40,7 @@ func TestWallet(t *testing.T) { wallet := Wallet{balance: startingBalance} err := wallet.Withdraw(100) - assertError(t, err) + assertError(t, err, "not enough to withdraw") assertBalance(t, wallet, startingBalance) }) }