Skip to content

Commit

Permalink
Reword the transfer test expectation actions
Browse files Browse the repository at this point in the history
  • Loading branch information
koden-km committed Aug 9, 2024
1 parent f78cd2b commit c65f504
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions domain/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func Test_Transfer_Refactor(t *testing.T) {
func(t *testing.T) {
var amount int64 = 100

whenAnnaSendsTransferToBobWithSufficientFunds := ExecuteCommand(commands.Transfer{
annaTransferToBobWithSufficientFunds := ExecuteCommand(commands.Transfer{
TransactionID: transactionID,
FromAccountID: annaAccountID,
ToAccountID: bobAccountID,
Expand Down Expand Up @@ -90,7 +90,7 @@ func Test_Transfer_Refactor(t *testing.T) {
depositForAnna,
).
Expect(
whenAnnaSendsTransferToBobWithSufficientFunds,
annaTransferToBobWithSufficientFunds,
AllOf(
theTransferIsApproved,
annaIsDebited,
Expand All @@ -110,7 +110,7 @@ func Test_Transfer_Refactor(t *testing.T) {
func(t *testing.T) {
var amount int64 = 1000

whenAnnaSendsTransferToBobWithInsufficientFunds := ExecuteCommand(commands.Transfer{
annaTransferToBobWithInsufficientFunds := ExecuteCommand(commands.Transfer{
TransactionID: transactionID,
FromAccountID: annaAccountID,
ToAccountID: bobAccountID,
Expand All @@ -126,8 +126,10 @@ func Test_Transfer_Refactor(t *testing.T) {
Reason: messages.InsufficientFunds,
})

annaIsDebited := ToRecordEventOfType(events.AccountDebited{})
bobIsCredited := ToRecordEventOfType(events.AccountCredited{})
theAccountsDoNotGetDebitedOrCredited := NoneOf(
ToRecordEventOfType(events.AccountDebited{}), // anna
ToRecordEventOfType(events.AccountCredited{}), // bob
)

Begin(t, &example.App{}).
Prepare(
Expand All @@ -136,13 +138,10 @@ func Test_Transfer_Refactor(t *testing.T) {
depositForAnna,
).
Expect(
whenAnnaSendsTransferToBobWithInsufficientFunds,
annaTransferToBobWithInsufficientFunds,
AllOf(
theTransferIsDeclined,
NoneOf(
annaIsDebited,
bobIsCredited,
),
theAccountsDoNotGetDebitedOrCredited,
),
)
},
Expand All @@ -158,7 +157,7 @@ func Test_Transfer_Refactor(t *testing.T) {
func(t *testing.T) {
var amount int64 = expectedDailyDebitLimit

whenAnnaSendsTransferToBobWithoutExceedingDailyDebitLimit := ExecuteCommand(commands.Transfer{
annaTransferToBobWithoutExceedingDailyDebitLimit := ExecuteCommand(commands.Transfer{
TransactionID: transactionID,
FromAccountID: annaAccountID,
ToAccountID: bobAccountID,
Expand Down Expand Up @@ -195,7 +194,7 @@ func Test_Transfer_Refactor(t *testing.T) {
depositAboveDailyDebitLimitForAnna,
).
Expect(
whenAnnaSendsTransferToBobWithoutExceedingDailyDebitLimit,
annaTransferToBobWithoutExceedingDailyDebitLimit,
AllOf(
theTransferIsApproved,
annaIsDebited,
Expand All @@ -215,7 +214,7 @@ func Test_Transfer_Refactor(t *testing.T) {
func(t *testing.T) {
var amount int64 = expectedDailyDebitLimit + 1

whenAnnaSendsTransferToBobAndExceedsDailyDebitLimit := ExecuteCommand(commands.Transfer{
annaTransferToBobAndExceedsDailyDebitLimit := ExecuteCommand(commands.Transfer{
TransactionID: transactionID,
FromAccountID: annaAccountID,
ToAccountID: bobAccountID,
Expand Down Expand Up @@ -245,12 +244,10 @@ func Test_Transfer_Refactor(t *testing.T) {
depositAboveDailyDebitLimitForAnna,
).
Expect(
whenAnnaSendsTransferToBobAndExceedsDailyDebitLimit,
annaTransferToBobAndExceedsDailyDebitLimit,
AllOf(
theTransferIsDeclined,
NoneOf(
bobIsCredited,
),
NoneOf(bobIsCredited),
),
)
},
Expand All @@ -268,7 +265,7 @@ func Test_Transfer_Refactor(t *testing.T) {
startTime := time.Date(2001, time.February, 3, 11, 22, 33, 0, time.UTC)
timeInFuture := time.Date(2001, time.February, 4, 0, 0, 0, 0, time.UTC)

whenAnnaSendsTransferToBobScheduledInTheFuture := ExecuteCommand(commands.Transfer{
annaTransferToBobScheduledInTheFuture := ExecuteCommand(commands.Transfer{
TransactionID: transactionID,
FromAccountID: annaAccountID,
ToAccountID: bobAccountID,
Expand Down Expand Up @@ -317,7 +314,7 @@ func Test_Transfer_Refactor(t *testing.T) {
depositForAnna,
).
Expect(
whenAnnaSendsTransferToBobScheduledInTheFuture,
annaTransferToBobScheduledInTheFuture,
AllOf(
theTransferIsNotYetApproved,
NoneOf(
Expand Down

0 comments on commit c65f504

Please sign in to comment.