New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#105] Web API integration tests #116
Conversation
tests/server-integration/Utils.hs
Outdated
( mconcat | ||
[ header "token" "root" | ||
, "path" =: path | ||
, "field" =: name | ||
, port 8081 | ||
] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically we have this repeated all over tests. Mb it would be suitable to extract to Utils.
And it will significantly reduce time to change port/header if needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I think we should have a function that captures whatever's common to all (or at least to most) requests.
They all have the same base URL, they all use runReq defaultHttpConfig + req
, they all have the token
header and the same port.
Then I only have to choose the verb, the rest of the URL, any additional headers, the request body, and ignoreResponse vs jsonResponse
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
6b207c6
to
4895df1
Compare
Could you please also add a commit deleting the javascript tests? |
bc320a4
to
96dd437
Compare
$ t1 <= newModifiedDate && newModifiedDate <= t2 | ||
|
||
assertBool "Dates are equal" | ||
$ responseBody response ^?! key "dateModified" . _JSON == newModifiedDate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check seems redundant.
let newModifiedDate = responseBody response ^?! key "dateModified" . _JSON @_ @UTCTime
responseBody response ^?! key "dateModified" . _JSON == newModifiedDate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set-field
: updates the entry's and the field's modified date
Hmm, I thought that we want to check all these things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but this particular check in line 160 is comparing an expression against itself:
let newModifiedDate = responseBody response ^?! key "dateModified" . _JSON @_ @UTCTime
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
responseBody response ^?! key "dateModified" . _JSON == newModifiedDate
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set-field
: updates the entry's and the field's modified date
You're already checking those two requirements in lines 157 and 162:
assertBool "Date is not recent"
$ t1 <= newModifiedDate && newModifiedDate <= t2
^^^^^^^^^^^^^^^^^ this checks that the entry's date was modified
assertBool "Dates are not equal"
$ responseBody response ^?! key "dateModified" . _JSON == newModifiedDate
assertBool "Dates are not equal"
$ responseBody response ^?! key "fields" . key "field" . key "dateModified" . _JSON == newModifiedDate
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this checks that the field's date was modified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good 👍
sry for a big delay
) | ||
deleteRecords = void $ try @Req.HttpException do | ||
executeCommand | ||
DELETE ["delete"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stand out from overall code style
look at 104, 107 ...
Problems: we have only 2 integration tests for Web API. We should create more tests Solution: add basic integration tests for every Web API endpoint.
153d446
to
61aa20c
Compare
Description
Problem
We have only 2 integration tests for Web API.
We should create more tests
Solution
Add basic integration tests for every Web API endpoint.
Related issue(s)
Fixed #
✅ Checklist for your Pull Request
Related changes (conditional)
Tests
silently reappearing again.
Documentation
Stylistic guide (mandatory)