Skip to content
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

Remove all keys before running tests #368

Open
brunoocasali opened this issue Aug 11, 2022 · 2 comments
Open

Remove all keys before running tests #368

brunoocasali opened this issue Aug 11, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@brunoocasali
Copy link
Member

Currently, in the tests (especially KeysAndPermissionsTest.php) we manually remove the created keys using $this->client->deleteKey. This is good, but we can do better.

The idea of this issue is to create a way of doing that for every test. We can use setUp() hook for that.

This will probably break some tests where we rely on the default keys created by Meilisearch automatically, those tests now should set up their own keys before asserting on them.

@brunoocasali brunoocasali added enhancement New feature or request good first issue Good for newcomers labels Aug 11, 2022
@arifszn
Copy link

arifszn commented Oct 11, 2022

The expectation is to not use $this->client->deleteKey in every test cases?

As the deleteKey should be executed after completing running the tests, shouldn't we use tearDown hook?

@brunoocasali
Copy link
Member Author

The expectation is to not use $this->client->deleteKey in every test cases?

Yes, we can use hooks for this kind of setup/teardown.

As the deleteKey should be executed after completing running the tests, shouldn't we use tearDown hook?

I agree with you! But we can have the same behavior by using the setUp, I really like this reference from cypress when it comes to why using after hooks is not that good, https://docs.cypress.io/guides/references/best-practices#Using-after-or-afterEach-hooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants