Skip to content

Commit

Permalink
fix: Fix splitdim tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rg0now committed Oct 12, 2023
1 parent 4ddd98b commit 871fd6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 99-labs/03-splitdim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ Before we start, below is a list of useful functions that help dealing with enco
- return HTTP 400 error status (`http.StatusBadRequest`) if any of these checks fail,
- log the request,
- call `db.Transfer` to process the request (this will currently call the placeholder, we will implement this in the next step),
- return HTTP 500 error status (`http.StatusInternalServerError`) if something went wrong and write the error message into the response body,
- return HTTP 400 error status (`http.StatusBadRequest`) if something went wrong and write the error message into the response body,
- if all went well, return HTTP 200 (`http.StatusOK`).
1. Implement the `db.Transfer(t)` call from the above. This will require extending the below function in the `pkg/db/local` package:
Expand Down
7 changes: 6 additions & 1 deletion 99-labs/code/splitdim/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ func TestTransfer(t *testing.T) {
assert.Equal(t, http.StatusBadRequest, res.StatusCode, "status")

// test with wrong JSON
res, err = testHTTP(t, "api/transfer", "POST", `{"a":12}`)
res, err = testHTTP(t, "api/transfer", "POST", `{"a":12`)
assert.NoError(t, err, "POST: api/transfer")
assert.Equal(t, http.StatusBadRequest, res.StatusCode, "status")

// test with same sender and receiver
res, err = testHTTP(t, "api/transfer", "POST", `{"sender":"a", "receiver": "a", "amount": 12}`)
assert.NoError(t, err, "POST: api/transfer")
assert.Equal(t, http.StatusBadRequest, res.StatusCode, "status")

Expand Down

0 comments on commit 871fd6c

Please sign in to comment.