@@ -281,6 +281,36 @@ func (suite *TestSuiteEnv) TestUpdateTransactionNegativeAmount() {
281281 test .AssertHTTPStatus (suite .T (), http .StatusBadRequest , & recorder )
282282}
283283
284+ func (suite * TestSuiteEnv ) TestUpdateTransactionEmptySourceDestinationAccount () {
285+ transaction := createTestTransaction (suite .T (), models.TransactionCreate {Amount : decimal .NewFromFloat (382.18 )})
286+
287+ recorder := test .Request (suite .T (), http .MethodPatch , transaction .Data .Links .Self , models.TransactionCreate {SourceAccountID : uuid .New ()})
288+ test .AssertHTTPStatus (suite .T (), http .StatusNotFound , & recorder )
289+
290+ recorder = test .Request (suite .T (), http .MethodPatch , transaction .Data .Links .Self , models.TransactionCreate {DestinationAccountID : uuid .New ()})
291+ test .AssertHTTPStatus (suite .T (), http .StatusNotFound , & recorder )
292+ }
293+
294+ func (suite * TestSuiteEnv ) TestUpdateNoEnvelopeTransactionOutgoing () {
295+ envelope := createTestEnvelope (suite .T (), models.EnvelopeCreate {})
296+
297+ c := models.TransactionCreate {
298+ BudgetID : createTestBudget (suite .T (), models.BudgetCreate {Name : "Testing budget for updating of outgoing transfer" }).Data .ID ,
299+ SourceAccountID : createTestAccount (suite .T (), models.AccountCreate {Name : "Internal Source Account" , External : false }).Data .ID ,
300+ DestinationAccountID : createTestAccount (suite .T (), models.AccountCreate {Name : "External destination account" , External : true }).Data .ID ,
301+ EnvelopeID : & envelope .Data .ID ,
302+ Amount : decimal .NewFromFloat (984.13 ),
303+ }
304+
305+ transaction := createTestTransaction (suite .T (), c )
306+
307+ recorder := test .Request (suite .T (), http .MethodPatch , transaction .Data .Links .Self , `{ "envelopeId": null }` )
308+ test .AssertHTTPStatus (suite .T (), http .StatusBadRequest , & recorder )
309+
310+ err := test .DecodeError (suite .T (), recorder .Body .Bytes ())
311+ assert .Equal (suite .T (), "For incoming and outgoing transactions, an envelope is required" , err , "request id %s" , recorder .Header ().Get ("x-request-id" ))
312+ }
313+
284314func (suite * TestSuiteEnv ) TestUpdateNonExistingTransaction () {
285315 recorder := test .Request (suite .T (), http .MethodPatch , "http://example.com/v1/transactions/6ae3312c-23cf-4225-9a81-4f218ba41b00" , `{ "note": "2" }` )
286316 test .AssertHTTPStatus (suite .T (), http .StatusNotFound , & recorder )
0 commit comments