MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestGetAccount

Function TestGetAccount

api/accounts_test.go:69–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func TestGetAccount(t *testing.T) {
70 router, b, err := setupRouter(t)
71 if err != nil {
72 t.Fatalf("Failed to setup router: %v", err)
73 }
74
75 newLedger, err := b.CreateLedger(model.Ledger{Name: gofakeit.Name()})
76 if err != nil {
77 t.Fatalf("Failed to create ledger: %v", err)
78 }
79
80 newBalance, err := b.CreateBalance(context.Background(), model.Balance{
81 LedgerID: newLedger.LedgerID,
82 Currency: gofakeit.CurrencyShort(),
83 })
84 if err != nil {
85 t.Fatalf("Failed to create balance: %v", err)
86 }
87
88 newIdentity, err := b.CreateIdentity(model.Identity{
89 FirstName: gofakeit.FirstName(),
90 LastName: gofakeit.LastName(),
91 EmailAddress: gofakeit.Email(),
92 Category: "individual",
93 })
94 if err != nil {
95 t.Fatalf("Failed to create identity: %v", err)
96 }
97
98 newAccount, err := b.CreateAccount(model.Account{
99 BankName: "Test Bank",
100 Number: gofakeit.AchAccount(),
101 LedgerID: newLedger.LedgerID,
102 BalanceID: newBalance.BalanceID,
103 IdentityID: newIdentity.IdentityID,
104 })
105 if err != nil {
106 t.Fatalf("Failed to create account: %v", err)
107 }
108
109 var response model.Account
110 testRequest := TestRequest{
111 Payload: nil,
112 Response: &response,
113 Method: "GET",
114 Route: fmt.Sprintf("/accounts/%s", newAccount.AccountID),
115 Auth: "",
116 Router: router,
117 }
118
119 resp, err := SetUpTestRequest(testRequest)
120 if err != nil {
121 t.Error(err)
122 return
123 }
124 assert.Equal(t, http.StatusOK, resp.Code)
125 assert.Equal(t, newAccount.AccountID, response.AccountID)
126}

Callers

nothing calls this directly

Calls 7

setupRouterFunction · 0.85
SetUpTestRequestFunction · 0.85
CreateLedgerMethod · 0.65
CreateBalanceMethod · 0.65
CreateIdentityMethod · 0.65
CreateAccountMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected