Compare commits

..

2 Commits

Author SHA1 Message Date
35b35f5e40
Implements /transactions PUT method
Adds PUT method to OpenAPI spec.

Given that the transaction IDs are generated on server-side, for the PUT
method to remain idempotent, it can only update existing transactions.

It also adds a TransactionExists method on the DAL.

Issue: #20
2024-06-22 21:51:03 +01:00
4c82ca0e2b
Implements /transactions POST method
It adds the method to the OpenAPI spec and generates a new server
config. The requirement for the ID on the Transaction component is
removed, so that it can be reused for insertions.
It also adds two new middlewares, a logging and a spec validator. If a
request does not follow the spec, a 400 is returned immediately.

Issue: #18
2024-06-22 20:11:52 +01:00
2 changed files with 2 additions and 2 deletions

View File

@ -55,7 +55,7 @@ func (dal *DalImpl) InsertTransaction(t entity.Transaction) (entity.Transaction,
} }
stmt := ` stmt := `
INSERT INTO pfbudget.transactions (date, description, value) INSERT INTO pfbudget.transactions (date, description, amount)
VALUES ($1, $2, $3) VALUES ($1, $2, $3)
RETURNING id RETURNING id
` `

View File

@ -297,7 +297,7 @@ func TestDalImpl_InsertTransaction(t *testing.T) {
mock. mock.
ExpectQuery(` ExpectQuery(`
INSERT INTO .* \(date, description, value\) INSERT INTO .* \(date, description, amount\)
VALUES \(\$1, \$2, \$3\) VALUES \(\$1, \$2, \$3\)
RETURNING id`). RETURNING id`).
WithArgs(tt.args.t.Date, tt.args.t.Description, tt.args.t.Value). WithArgs(tt.args.t.Date, tt.args.t.Description, tt.args.t.Value).