Skip to content

Commit

Permalink
developing unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Cataldo committed Dec 4, 2023
1 parent 565fc69 commit f131193
Show file tree
Hide file tree
Showing 15 changed files with 393 additions and 556 deletions.
104 changes: 13 additions & 91 deletions asaas/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"
)

func TestAccountSaveInvoiceCustomizationSuccess(t *testing.T) {
func TestAccountSaveInvoiceCustomization(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
f, err := os.Open(getEnvValue(EnvImageName))
Expand All @@ -25,13 +25,7 @@ func TestAccountSaveInvoiceCustomizationSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountSaveInvoiceCustomizationError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, err := nAccount.SaveInvoiceCustomization(context.TODO(), SaveInvoiceCustomizationRequest{})
assertResponseFailure(t, resp, err)
}

func TestAccountUpdateSuccess(t *testing.T) {
func TestAccountUpdate(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -55,13 +49,7 @@ func TestAccountUpdateSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountUpdateError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, err := nAccount.Update(context.TODO(), UpdateAccountRequest{})
assertResponseFailure(t, resp, err)
}

func TestAccountDeleteWhiteLabelSubaccountSuccess(t *testing.T) {
func TestAccountDeleteWhiteLabelSubaccount(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -73,13 +61,7 @@ func TestAccountDeleteWhiteLabelSubaccountSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountDeleteWhiteLabelSubaccountError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, err := nAccount.DeleteWhiteLabelSubaccount(context.TODO(), DeleteWhiteLabelSubaccountRequest{})
assertResponseFailure(t, resp, err)
}

func TestAccountGetSuccess(t *testing.T) {
func TestAccountGet(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -89,13 +71,7 @@ func TestAccountGetSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountGetError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, errAsaas := nAccount.Get(context.TODO())
assertResponseFailure(t, resp, errAsaas)
}

func TestAccountGetRegistrationStatusSuccess(t *testing.T) {
func TestAccountGetRegistrationStatus(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -105,13 +81,7 @@ func TestAccountGetRegistrationStatusSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountGetRegistrationStatusError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, errAsaas := nAccount.Get(context.TODO())
assertResponseFailure(t, resp, errAsaas)
}

func TestAccountGetBankInfoSuccess(t *testing.T) {
func TestAccountGetBankInfo(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -121,13 +91,7 @@ func TestAccountGetBankInfoSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountGetBankInfoError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, errAsaas := nAccount.GetBankInfo(context.TODO())
assertResponseFailure(t, resp, errAsaas)
}

func TestAccountGetFeesSuccess(t *testing.T) {
func TestAccountGetFees(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -137,13 +101,7 @@ func TestAccountGetFeesSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountGetFeesError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, errAsaas := nAccount.GetFees(context.TODO())
assertResponseFailure(t, resp, errAsaas)
}

func TestAccountGetWalletsSuccess(t *testing.T) {
func TestAccountGetWallets(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -153,13 +111,7 @@ func TestAccountGetWalletsSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountGetWalletsError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, errAsaas := nAccount.GetWallets(context.TODO())
assertResponseFailure(t, resp, errAsaas)
}

func TestAccountGetBalanceSuccess(t *testing.T) {
func TestAccountGetBalance(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -169,13 +121,7 @@ func TestAccountGetBalanceSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountGetBalanceError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, errAsaas := nAccount.GetWallets(context.TODO())
assertResponseFailure(t, resp, errAsaas)
}

func TestAccountGetAccountStatementSuccess(t *testing.T) {
func TestAccountGetAccountStatement(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -191,13 +137,7 @@ func TestAccountGetAccountStatementSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountGetAccountStatementError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, errAsaas := nAccount.GetAccountStatement(context.TODO(), GetAccountStatementRequest{})
assertResponseFailure(t, resp, errAsaas)
}

func TestAccountGetPaymentStatisticSuccess(t *testing.T) {
func TestAccountGetPaymentStatistic(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -219,13 +159,7 @@ func TestAccountGetPaymentStatisticSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountGetPaymentStatisticError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, errAsaas := nAccount.GetPaymentStatistic(context.TODO(), GetPaymentStatisticRequest{})
assertResponseFailure(t, resp, errAsaas)
}

func TestAccountGetSplitStatisticSuccess(t *testing.T) {
func TestAccountGetSplitStatistic(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -235,13 +169,7 @@ func TestAccountGetSplitStatisticSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountGetSplitStatisticError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, errAsaas := nAccount.GetSplitStatistic(context.TODO())
assertResponseFailure(t, resp, errAsaas)
}

func TestAccountGetInvoiceCustomizationSuccess(t *testing.T) {
func TestAccountGetInvoiceCustomization(t *testing.T) {
accessToken := getEnvValue(EnvAccessTokenSecondary)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -250,9 +178,3 @@ func TestAccountGetInvoiceCustomizationSuccess(t *testing.T) {
resp, errAsaas := nAccount.GetInvoiceCustomization(ctx)
assertResponseSuccess(t, resp, errAsaas)
}

func TestAccountGetInvoiceCustomizationError(t *testing.T) {
nAccount := NewAccount(EnvSandbox, "")
resp, errAsaas := nAccount.GetInvoiceCustomization(context.TODO())
assertResponseFailure(t, resp, errAsaas)
}
48 changes: 6 additions & 42 deletions asaas/anticipation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"
)

func TestAnticipationSimulateSuccess(t *testing.T) {
func TestAnticipationSimulate(t *testing.T) {
accessToken := getEnvValue(EnvAccessToken)
assertFatalStringBlank(t, accessToken)
initCreditCardCharge(true, false)
Expand All @@ -22,13 +22,7 @@ func TestAnticipationSimulateSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAnticipationSimulateError(t *testing.T) {
nAnticipation := NewAnticipation(EnvSandbox, "")
resp, err := nAnticipation.Simulate(context.TODO(), AnticipationSimulateRequest{})
assertResponseFailure(t, resp, err)
}

func TestAnticipationRequestSuccess(t *testing.T) {
func TestAnticipationRequest(t *testing.T) {
accessToken := getEnvValue(EnvAccessToken)
assertFatalStringBlank(t, accessToken)
initCreditCardCharge(true, false)
Expand All @@ -45,13 +39,7 @@ func TestAnticipationRequestSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAnticipationRequestError(t *testing.T) {
nAnticipation := NewAnticipation(EnvSandbox, "")
resp, err := nAnticipation.Request(context.TODO(), AnticipationRequest{})
assertResponseFailure(t, resp, err)
}

func TestAnticipationAgreementSignSuccess(t *testing.T) {
func TestAnticipationAgreementSign(t *testing.T) {
accessToken := getEnvValue(EnvAccessToken)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -63,13 +51,7 @@ func TestAnticipationAgreementSignSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAnticipationAgreementSignError(t *testing.T) {
nAnticipation := NewAnticipation(EnvSandbox, "")
resp, err := nAnticipation.AgreementSign(context.TODO(), AgreementSignRequest{})
assertResponseFailure(t, resp, err)
}

func TestAnticipationGetByIdSuccess(t *testing.T) {
func TestAnticipationGetById(t *testing.T) {
accessToken := getEnvValue(EnvAccessToken)
assertFatalStringBlank(t, accessToken)
initAnticipation()
Expand All @@ -81,13 +63,7 @@ func TestAnticipationGetByIdSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAnticipationGetByIdError(t *testing.T) {
nAnticipation := NewAnticipation(EnvSandbox, "")
resp, err := nAnticipation.GetById(context.TODO(), "")
assertResponseFailure(t, resp, err)
}

func TestAnticipationGetLimitsSuccess(t *testing.T) {
func TestAnticipationGetLimits(t *testing.T) {
accessToken := getEnvValue(EnvAccessToken)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -97,13 +73,7 @@ func TestAnticipationGetLimitsSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestAnticipationGetLimitsError(t *testing.T) {
nAnticipation := NewAnticipation(EnvSandbox, "")
resp, errAsaas := nAnticipation.GetLimits(context.TODO())
assertResponseFailure(t, resp, errAsaas)
}

func TestAnticipationGetAllSuccess(t *testing.T) {
func TestAnticipationGetAll(t *testing.T) {
accessToken := getEnvValue(EnvAccessToken)
assertFatalStringBlank(t, accessToken)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
Expand All @@ -118,9 +88,3 @@ func TestAnticipationGetAllSuccess(t *testing.T) {
})
assertResponseSuccess(t, resp, errAsaas)
}

func TestAnticipationGetAllError(t *testing.T) {
nAnticipation := NewAnticipation(EnvSandbox, "")
resp, errAsaas := nAnticipation.GetAll(context.TODO(), GetAllAnticipationsRequest{})
assertResponseFailure(t, resp, errAsaas)
}
40 changes: 5 additions & 35 deletions asaas/bill_payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"
)

func TestBillPaymentSimulateSuccess(t *testing.T) {
func TestBillPaymentSimulate(t *testing.T) {
accessToken := getEnvValue(EnvAccessToken)
assertFatalStringBlank(t, accessToken)
identificationField := getEnvValue(EnvChargeIdentificationField)
Expand All @@ -21,13 +21,7 @@ func TestBillPaymentSimulateSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestBillPaymentSimulateError(t *testing.T) {
nBillPayment := NewBillPayment(EnvSandbox, "")
resp, err := nBillPayment.Create(context.TODO(), CreateBillPaymentRequest{})
assertResponseFailure(t, resp, err)
}

func TestBillPaymentCreateSuccess(t *testing.T) {
func TestBillPaymentCreate(t *testing.T) {
accessToken := getEnvValue(EnvAccessToken)
assertFatalStringBlank(t, accessToken)
identificationField := getEnvValue(EnvChargeIdentificationField)
Expand All @@ -48,13 +42,7 @@ func TestBillPaymentCreateSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestBillPaymentCreateError(t *testing.T) {
nBillPayment := NewBillPayment(EnvSandbox, "")
resp, err := nBillPayment.Create(context.TODO(), CreateBillPaymentRequest{})
assertResponseFailure(t, resp, err)
}

func TestBillPaymentCancelByIdSuccess(t *testing.T) {
func TestBillPaymentCancelById(t *testing.T) {
accessToken := getEnvValue(EnvAccessToken)
assertFatalStringBlank(t, accessToken)
initBillPayment()
Expand All @@ -67,13 +55,7 @@ func TestBillPaymentCancelByIdSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestBillPaymentCancelByIdError(t *testing.T) {
nBillPayment := NewBillPayment(EnvSandbox, "")
resp, errAsaas := nBillPayment.CancelById(context.TODO(), "")
assertResponseFailure(t, resp, errAsaas)
}

func TestBillPaymentGetByIdSuccess(t *testing.T) {
func TestBillPaymentGetById(t *testing.T) {
accessToken := getEnvValue(EnvAccessToken)
assertFatalStringBlank(t, accessToken)
initBillPayment()
Expand All @@ -86,13 +68,7 @@ func TestBillPaymentGetByIdSuccess(t *testing.T) {
assertResponseSuccess(t, resp, errAsaas)
}

func TestBillPaymentGetIdError(t *testing.T) {
nBillPayment := NewBillPayment(EnvSandbox, "")
resp, errAsaas := nBillPayment.GetById(context.TODO(), "")
assertResponseFailure(t, resp, errAsaas)
}

func TestBillPaymentGetAllSuccess(t *testing.T) {
func TestBillPaymentGetAll(t *testing.T) {
accessToken := getEnvValue(EnvAccessToken)
assertFatalStringBlank(t, accessToken)
initBillPayment()
Expand All @@ -102,9 +78,3 @@ func TestBillPaymentGetAllSuccess(t *testing.T) {
resp, errAsaas := nBillPayment.GetAll(ctx, PageableDefaultRequest{})
assertResponseSuccess(t, resp, errAsaas)
}

func TestBillPaymentGetAllError(t *testing.T) {
nBillPayment := NewBillPayment(EnvSandbox, "")
resp, errAsaas := nBillPayment.GetAll(context.TODO(), PageableDefaultRequest{})
assertResponseFailure(t, resp, errAsaas)
}
Loading

0 comments on commit f131193

Please sign in to comment.