@@ -268,7 +268,7 @@ Pretty much the opposite of `Deposit()`
268
268
``` go
269
269
func TestWallet (t *testing .T ) {
270
270
271
- t.Run (" Deposit " , func (t *testing.T ) {
271
+ t.Run (" deposit " , func (t *testing.T ) {
272
272
wallet := Wallet{}
273
273
274
274
wallet.Deposit (Bitcoin (10 ))
@@ -282,7 +282,7 @@ func TestWallet(t *testing.T) {
282
282
}
283
283
})
284
284
285
- t.Run (" Withdraw " , func (t *testing.T ) {
285
+ t.Run (" withdraw " , func (t *testing.T ) {
286
286
wallet := Wallet{balance: Bitcoin (20 )}
287
287
288
288
wallet.Withdraw (Bitcoin (10 ))
@@ -336,13 +336,13 @@ func TestWallet(t *testing.T) {
336
336
}
337
337
}
338
338
339
- t.Run (" Deposit " , func (t *testing.T ) {
339
+ t.Run (" deposit " , func (t *testing.T ) {
340
340
wallet := Wallet{}
341
341
wallet.Deposit (Bitcoin (10 ))
342
342
assertBalance (t, wallet, Bitcoin (10 ))
343
343
})
344
344
345
- t.Run (" Withdraw " , func (t *testing.T ) {
345
+ t.Run (" withdraw " , func (t *testing.T ) {
346
346
wallet := Wallet{balance: Bitcoin (20 )}
347
347
wallet.Withdraw (Bitcoin (10 ))
348
348
assertBalance (t, wallet, Bitcoin (10 ))
@@ -362,7 +362,7 @@ Let's try this out in a test.
362
362
## Write the test first
363
363
364
364
``` go
365
- t.Run (" Withdraw insufficient funds" , func (t *testing.T ) {
365
+ t.Run (" withdraw insufficient funds" , func (t *testing.T ) {
366
366
startingBalance := Bitcoin (20 )
367
367
wallet := Wallet {startingBalance}
368
368
err := wallet.Withdraw (Bitcoin (100 ))
@@ -434,7 +434,7 @@ assertError := func(t testing.TB, err error) {
434
434
And in our test
435
435
436
436
``` go
437
- t.Run (" Withdraw insufficient funds" , func (t *testing.T ) {
437
+ t.Run (" withdraw insufficient funds" , func (t *testing.T ) {
438
438
startingBalance := Bitcoin (20 )
439
439
wallet := Wallet {startingBalance}
440
440
err := wallet.Withdraw (Bitcoin (100 ))
@@ -468,7 +468,7 @@ assertError := func(t testing.TB, got error, want string) {
468
468
And then update the caller
469
469
470
470
``` go
471
- t.Run (" Withdraw insufficient funds" , func (t *testing.T ) {
471
+ t.Run (" withdraw insufficient funds" , func (t *testing.T ) {
472
472
startingBalance := Bitcoin (20 )
473
473
wallet := Wallet {startingBalance}
474
474
err := wallet.Withdraw (Bitcoin (100 ))
@@ -529,19 +529,19 @@ Next we can refactor our test code to use this value instead of specific strings
529
529
``` go
530
530
func TestWallet (t *testing .T ) {
531
531
532
- t.Run (" Deposit " , func (t *testing.T ) {
532
+ t.Run (" deposit " , func (t *testing.T ) {
533
533
wallet := Wallet{}
534
534
wallet.Deposit (Bitcoin (10 ))
535
535
assertBalance (t, wallet, Bitcoin (10 ))
536
536
})
537
537
538
- t.Run (" Withdraw with funds" , func (t *testing.T ) {
538
+ t.Run (" withdraw with funds" , func (t *testing.T ) {
539
539
wallet := Wallet{Bitcoin (20 )}
540
540
wallet.Withdraw (Bitcoin (10 ))
541
541
assertBalance (t, wallet, Bitcoin (10 ))
542
542
})
543
543
544
- t.Run (" Withdraw insufficient funds" , func (t *testing.T ) {
544
+ t.Run (" withdraw insufficient funds" , func (t *testing.T ) {
545
545
wallet := Wallet{Bitcoin (20 )}
546
546
err := wallet.Withdraw (Bitcoin (100 ))
547
547
@@ -598,22 +598,22 @@ Here is the final test code that accounts for this.
598
598
``` go
599
599
func TestWallet (t *testing .T ) {
600
600
601
- t.Run (" Deposit " , func (t *testing.T ) {
601
+ t.Run (" deposit " , func (t *testing.T ) {
602
602
wallet := Wallet{}
603
603
wallet.Deposit (Bitcoin (10 ))
604
604
605
605
assertBalance (t, wallet, Bitcoin (10 ))
606
606
})
607
607
608
- t.Run (" Withdraw with funds" , func (t *testing.T ) {
608
+ t.Run (" withdraw with funds" , func (t *testing.T ) {
609
609
wallet := Wallet{Bitcoin (20 )}
610
610
err := wallet.Withdraw (Bitcoin (10 ))
611
611
612
612
assertNoError (t, err)
613
613
assertBalance (t, wallet, Bitcoin (10 ))
614
614
})
615
615
616
- t.Run (" Withdraw insufficient funds" , func (t *testing.T ) {
616
+ t.Run (" withdraw insufficient funds" , func (t *testing.T ) {
617
617
wallet := Wallet{Bitcoin (20 )}
618
618
err := wallet.Withdraw (Bitcoin (100 ))
619
619
0 commit comments