Skip to content

Commit dccc5ae

Browse files
committed
✨ (bitcoin-wallet): add withdraw test
1 parent dfcc397 commit dccc5ae

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

pointers-and-errors/bitcoin-and-wallet_test.go

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,28 @@ import "testing"
44

55
// Bitcoin Wallet
66
func TestWallet(t *testing.T) {
7-
wallet := Wallet{}
8-
9-
wallet.Deposit(10)
10-
got := wallet.Balance()
11-
want := Bitcoin(10)
12-
if got != want {
13-
t.Errorf("got %v, want %v", got, want)
14-
}
7+
t.Run("deposit", func(t *testing.T) {
8+
wallet := Wallet{}
9+
10+
wallet.Deposit(10)
11+
got := wallet.Balance()
12+
want := Bitcoin(10)
13+
if got != want {
14+
t.Errorf("got %v, want %v", got, want)
15+
}
16+
})
17+
18+
t.Run("withdraw", func(t *testing.T) {
19+
wallet := Wallet{balance: Bitcoin(20)}
20+
21+
wallet.Withdraw(Bitcoin(10))
22+
23+
got := wallet.Balance()
24+
25+
want := Bitcoin(10)
26+
27+
if got != want {
28+
t.Errorf("got %s want %s", got, want)
29+
}
30+
})
1531
}

0 commit comments

Comments
 (0)