This repository has been archived by the owner on Oct 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Big progress on transactions endpoints.
- Loading branch information
1 parent
59ad038
commit 531fcac
Showing
10 changed files
with
416 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package controller_test | ||
|
||
import ( | ||
"github.com/harderthanitneedstobe/rest-api/v0/pkg/models" | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func TestPostTransactions(t *testing.T) { | ||
t.Run("bad request", func(t *testing.T) { | ||
e := NewTestApplication(t) | ||
token := GivenIHaveToken(t, e) | ||
|
||
response := e.POST("/bank_accounts/1234/transactions"). | ||
WithHeader("H-Token", token). | ||
WithJSON(models.Transaction{ | ||
BankAccountId: 1234, | ||
ExpenseId: nil, | ||
Categories: []string{ | ||
"Things", | ||
}, | ||
Name: "I spent money", | ||
MerchantName: "A place", | ||
IsPending: false, | ||
}). | ||
Expect() | ||
|
||
response.Status(http.StatusBadRequest) | ||
response.JSON().Path("$.error").Equal("cannot create transactions for non-manual links") | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package fixtures | ||
|
||
import ( | ||
"github.com/brianvoe/gofakeit/v6" | ||
"github.com/harderthanitneedstobe/rest-api/v0/pkg/models" | ||
"testing" | ||
) | ||
|
||
func BankAccountFixture(t *testing.T) *models.BankAccount { | ||
return &models.BankAccount{ | ||
PlaidAccountId: gofakeit.UUID(), | ||
AvailableBalance: 100000, | ||
CurrentBalance: 98500, | ||
Mask: "0123", | ||
Name: "Personal Checking", | ||
PlaidName: "Checking", | ||
PlaidOfficialName: "Checking", | ||
Type: "depository", | ||
SubType: "checking", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package fixtures | ||
|
||
import ( | ||
"fmt" | ||
"github.com/brianvoe/gofakeit/v6" | ||
"github.com/harderthanitneedstobe/rest-api/v0/pkg/models" | ||
"testing" | ||
) | ||
|
||
func ManualLink(t *testing.T) *models.Link { | ||
return &models.Link{ | ||
LinkType: models.ManualLinkType, | ||
InstitutionName: fmt.Sprintf("%s Bank", gofakeit.Company()), | ||
CustomInstitutionName: "Personal Bank", | ||
} | ||
} | ||
|
||
func PlaidLink(t *testing.T) (*models.Link, *models.PlaidLink) { | ||
return &models.Link{ | ||
LinkType: models.ManualLinkType, | ||
InstitutionName: fmt.Sprintf("%s Bank", gofakeit.Company()), | ||
CustomInstitutionName: "Personal Bank", | ||
}, &models.PlaidLink{ | ||
ItemId: gofakeit.UUID(), | ||
AccessToken: gofakeit.UUID(), | ||
Products: []string{ | ||
"transactions", | ||
}, | ||
WebhookUrl: "", | ||
InstitutionId: "1234", | ||
InstitutionName: gofakeit.Company(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.