-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make transaction-rollback=true the default for test-suite #1663
Make transaction-rollback=true the default for test-suite #1663
Conversation
67c0883
to
5b3ec80
Compare
And I did not run the tests against the same database without recreation yet. That's something that I want to do as well, I'm pretty sure some more failing tests will come up. |
5b3ec80
to
426a304
Compare
426a304
to
0294c31
Compare
@wolfgangwalther A rebase here would be good. I'll carefully review this one in case something slips by on the modified tests. |
Rebased.
Yes, that would be great, thanks! If possible, you could also try to run the tests twice against the same database, without re-creating the schema. I haven't been able to do that, yet. And I think the tests about "execute a rpc only once per request" need special attention as well. Not sure right now, if I even touched them, but they for sure need to keep state on the database. So they probably need to clean up as well, not sure they do. |
0294c31
to
b7a6cf3
Compare
@wolfgangwalther Finally gave this one a review :) Check my above comments. I like that persistence in the tests has to be explicit now with
Not sure how to do that quickly :(. I just ran |
I somehow can't see my comment about this above easily, so I repeat what I wrote there, here: Not all errors need Prefer: tx=commit. Once you test for "non-persistance after an error" you need it. Most tests for errors do not have the "non-persistance test" part.
Yeah, I wasn't sure about that either. I think I now know how: I will just wrap two calls to |
So I did this, and it worked:
Showing another 6 failures. Will fix those in a 2nd commit, so you can review those independently. |
b7a6cf3
to
e01051e
Compare
Ok, this should be good to merge now from my perspective. |
@wolfgangwalther Same here. Looks good to go! |
…1663) Change test-suite to use db-tx-rollback-all = true by default
Follow-up on #1659:
This is based on the other PR, so the diff is a bit longer than it should be. Still, it's huge. I hope it looks better with "Hide whitespace changes" turned on.
Quick guide on how to look at this:
src/...
is from the other PR. Ignore here.test/Main.hs
andtest/SpecHelper.hs
. Removed the schema reloading, re-ordered the tests and enabledtransaction-rollback = true
. This caused a lot of broken tests.test/Feature/...
+test/fixtures/...
is fixing those tests, so that they don't depend on the result of other tests anymore. As always, every test-case I touched, I also reformatted / refactored. This might increase the diff here, but I hope to be able to make all those test-cases consistently structured down the road. This helps me a lot to understand the tests quickly when reading them. The changes to the tests, that I had to make to account for the rolled back transactions are often quite similar. For every kind of change, I will comment on an example.When refactoring / reformatting the tests, I did the following:
with:
Much easier to read, because it follows the same structure that almost all the tests have.
When possible replaced
request methodPost ...
with the short formpost ...
(for all http methods). Fewer empty arrays and empty bodies that way.Formatted the requests around
shouldRespondWith
with consistent indentation and newlines, like this:For me, it's much easier to immediately see what's going on, compared to when the
shouldRespondWith
is sometimes hidden somewhere on the same line as other things.Changed
[str|...json data...|]
to[json|...json data...|]
. This is essential, becauseshouldRespondWith
will then do a json-comparison and ignore formatting, which sometimes causes trouble. It does also include a check for theapplication/json
content-type by default. I don't think there were any changes of this, in this PR.Removed obsolete
matchContentTypeJson
(see last point why, it's included already) andmatchStatus = 200
(the default check).@steve-chavez do you think this formatting / structure for tests is something that we can "formalize" a bit more, even without a linter / style-check that covers for it? Any suggestions for improvement?