-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Provide method to teardown fixture data #89
Comments
I've also run into something similar and would benefit from something like this. EDIT: I was under the impression this was already happening from:
so maybe I'm doing something wrong? EDIT2: I'm doing:
|
Hi @sproutworks, I have the impression that the problem you're having is a consequence of how you're using testfixtures. Ideally, you should load all tables before every test. If you're loading only some tables than surely you can have integrity problems, but I think it's not the library's responsibility to prevent that. |
Hi, @andreynering! We are facing the same issue and would be so glad if there is a possibility to wipe test data after running a test. I hope this PR - #110 could give us such opportunity. In this case library's user would have a possibility to choose if he needs or not to clear the test data. |
@andreynering +1 to this. I think it´s a common use case to have a different set of data for different test scenarios. Ideally, fixtures should be able to clean themselves after each test. Is there any chance of #110 to be reviewed and merged? |
I've run into a situation where my build fails depending on the order of the tests and the nature of their foreign key relationships. I am using the UseAlterConstraint method with Postgres, and not running tests in parallel.
For example:
Test 1 creates fixtures for Table A & Table B. Table A has a record which references some record in Table B.
Test 2 only creates fixtures in Table B. Because there is leftover data in table A from test 1, now test 2 fails when testfixtures tries to clear Table B.
What I had to do to solve this is to copy the logic to make the constraints deferrable (I am using Postgres). Then I can do a teardown at the end of each test where I delete all the fixture data.
So what I am looking for is a method something like:
fixtures.Unload()
This would remove everything created by fixtures.Load(), to avoid potential conflicts with subsequent tests.
The text was updated successfully, but these errors were encountered: