(t *testing.T)
| 114 | } |
| 115 | |
| 116 | func TestGetBalance(t *testing.T) { |
| 117 | router, b, _ := setupRouter(t) |
| 118 | newLedger, err := b.CreateLedger(model.Ledger{Name: gofakeit.Name()}) |
| 119 | if err != nil { |
| 120 | return |
| 121 | } |
| 122 | newBalance, err := b.CreateBalance(context.Background(), model.Balance{LedgerID: newLedger.LedgerID, Currency: gofakeit.CurrencyShort()}) |
| 123 | if err != nil { |
| 124 | return |
| 125 | } |
| 126 | var response model.Balance |
| 127 | testRequest := TestRequest{ |
| 128 | Payload: nil, |
| 129 | Response: &response, |
| 130 | Method: "GET", |
| 131 | Route: fmt.Sprintf("/balances/%s", newBalance.BalanceID), |
| 132 | Auth: "", |
| 133 | Router: router, |
| 134 | } |
| 135 | resp, err := SetUpTestRequest(testRequest) |
| 136 | if err != nil { |
| 137 | t.Error(err) |
| 138 | return |
| 139 | } |
| 140 | assert.Equal(t, http.StatusOK, resp.Code) |
| 141 | assert.Equal(t, response.BalanceID, newBalance.BalanceID) |
| 142 | assert.Equal(t, response.LedgerID, newLedger.LedgerID) |
| 143 | assert.Equal(t, response.Currency, newBalance.Currency) |
| 144 | assert.Equal(t, big.NewInt(0), newBalance.Balance) |
| 145 | assert.Equal(t, big.NewInt(0), newBalance.DebitBalance) |
| 146 | assert.Equal(t, big.NewInt(0), newBalance.CreditBalance) |
| 147 | assert.Equal(t, big.NewInt(0), newBalance.InflightBalance) |
| 148 | assert.Equal(t, big.NewInt(0), newBalance.InflightCreditBalance) |
| 149 | assert.Equal(t, big.NewInt(0), newBalance.InflightDebitBalance) |
| 150 | assert.Equal(t, int64(0), newBalance.Version) |
| 151 | } |
| 152 | |
| 153 | func TestGetBalances(t *testing.T) { |
| 154 | router, b, err := setupRouter(t) |
nothing calls this directly
no test coverage detected