adonisjs / lucid

AdonisJS SQL ORM. Supports PostgreSQL, MySQL, MSSQL, Redshift, SQLite and many more
https://lucid.adonisjs.com/
MIT License
1.08k stars 195 forks source link

Add DatabaseTestUtils #988

Closed Julien-R44 closed 10 months ago

Julien-R44 commented 10 months ago

Changes

So every test in this group will be wrapped a transaction that will be reverted at the end of the test

Julien-R44 commented 10 months ago

tests will fail cause of the last two commits since we dont have TestUtils exported from @adonisjs/core/test_utils.

thetutlage commented 10 months ago

We should export TestUtils class from @adonisjs/core in order to be able to extend it with macros. Which export path should we use ? @adonisjs/core/test_utils' ? Let me know and I will make a PR on core

Yeah, we can export it from /test_utils submodule.

not sure about this one. Naively, i would say no, but : could it cause some problems to register testUtils bindings only in test environnement ?

We can use the container resolving hook. https://docs.adonisjs.com/guides/ioc-container#container-hooks

not sure here too. should we resolve the Ace binding immediately ?

Yeah, can be lazily resolved as someone uses one of the methods from the DatabaseTestUtils class.

Julien-R44 commented 10 months ago

Should be all good. Let me just know if we keep withGlobalTransaction or not. Also if naming look correct to you

thetutlage commented 10 months ago

Looks good.

We will have to create a new doc under the testing group, inside the AdonisJS documentation covering the usage of these hooks