@@ -86,6 +86,15 @@ func TestNoAccountNotFound(t *testing.T) {
8686 test .AssertHTTPStatus (t , http .StatusNotFound , & recorder )
8787}
8888
89+ // TestNonexistingBudgetAccounts404 is a regression test for https://github.com/envelope-zero/backend/issues/89.
90+ //
91+ // It verifies that for a non-existing budget, the accounts endpoint raises a 404
92+ // instead of returning an empty list.
93+ func TestNonexistingBudgetAccounts404 (t * testing.T ) {
94+ recorder := test .Request (t , "GET" , "/v1/budgets/999/accounts" , "" )
95+ test .AssertHTTPStatus (t , http .StatusNotFound , & recorder )
96+ }
97+
8998func TestCreateAccount (t * testing.T ) {
9099 recorder := test .Request (t , "POST" , "/v1/budgets/1/accounts" , `{ "name": "New Account", "note": "More tests something something" }` )
91100 test .AssertHTTPStatus (t , http .StatusCreated , & recorder )
@@ -144,15 +153,7 @@ func TestGetAccountTransactions(t *testing.T) {
144153
145154func TestGetAccountTransactionsNonExistingAccount (t * testing.T ) {
146155 recorder := test .Request (t , "GET" , "/v1/budgets/1/accounts/57372/transactions" , "" )
147-
148- var response TransactionListResponse
149- err := json .NewDecoder (recorder .Body ).Decode (& response )
150- if err != nil {
151- assert .Fail (t , "Unable to parse response from server %q into APIListResponse, '%v'" , recorder .Body , err )
152- }
153-
154156 assert .Equal (t , 404 , recorder .Code )
155- assert .Len (t , response .Data , 0 )
156157}
157158
158159func TestUpdateAccount (t * testing.T ) {
0 commit comments