meilisearch-rust icon indicating copy to clipboard operation
meilisearch-rust copied to clipboard

Improve the test macro

Open irevoire opened this issue 3 years ago • 6 comments

Currently, our test macro is missing two big features:

  • [x] It should catch all panic and delete the created Index if there was one and then output the panic normally to make the test fail
  • [ ] It should be able to understand path in the arguments

irevoire avatar Feb 14 '22 13:02 irevoire

If the index already exists it should still be deleted as we cannot guarantee that the settings are the ones required for the next tests.

To avoid this, we can always delete the index before creating one. If there is a direct error (no task) it will panic. In case a task is returns but the task fails because the index did not exists, it will be silently ignored.

bidoubiwa avatar Apr 25 '22 15:04 bidoubiwa

Super cool, I think we can keep the issue open, though because deleting the index at the end of the tests is faster. We don't need to wait until the update is processed and can let meilisearch process his tasks.

Also there was a second point in the issue :grin:

irevoire avatar Apr 25 '22 16:04 irevoire

Are you suggesting deleting the index only at the end of all the tests or at the end of every test?

It should be able to understand path in the arguments

Oh sorry, I thought it was linked!

bidoubiwa avatar Apr 25 '22 16:04 bidoubiwa

It is not a good thing to delete it after the test because if something happens before the test finishes, we will have an unwanted state. Since we are testing e2e we need to rely on the Meilisearch instance for everything, otherwise, we probably will end with a flaky test.

Good reference about the subject: https://docs.cypress.io/guides/references/best-practices#Using-after-or-afterEach-hooks

brunoocasali avatar Apr 25 '22 17:04 brunoocasali

Oooh, interesting. Thanks for the insight! Currently, the macro deletes the index if no error happens.

irevoire avatar Apr 26 '22 11:04 irevoire

Related to "understand paths" is the related one for setting up the client like this one?: "Client: It creates a client like that: Client::new("http://localhost:7700", "masterKey")."

carlosb1 avatar Aug 24 '23 10:08 carlosb1