meilisearch/meilisearch-rust

Improve the test macro

irevoire opened this issue ยท 6 comments

Currently, our test macro is missing two big features:

  • 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

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.

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 ๐Ÿ˜

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!

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

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

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")."