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

Respawn if there is nothing to clear at the moment doesn't work #124

Open
drauch opened this issue Jul 17, 2023 · 5 comments
Open

Respawn if there is nothing to clear at the moment doesn't work #124

drauch opened this issue Jul 17, 2023 · 5 comments

Comments

@drauch
Copy link

drauch commented Jul 17, 2023

Maybe we don't understand Respawn good enough and there is an easy workaround for this. We basically respawn in each SetUpFixture in our tests. However, sometimes there are no tables to clear and Respawn failed. To overcome this we've used the following workaroud: add an DbAdapter that checks in BuildDeleteCommandText whether the built commandText is empty and in that case throw a specific exception that we can catch and ignore when calling Respawner. Since 6.1.0 this is no longer possible according to one of my team mates.

Is there a real way to do this? If not, how to workaround this problem with v6.1.0?

Best regards,
D.R.

@jbogard
Copy link
Owner

jbogard commented Jul 17, 2023

Why are there no tables to clear? That sounds like a bug.

@chrischu
Copy link

Well as my colleague explained, we do that in the SetUpFixture of our tests, so we have cases where the database is actually empty (because nothing ran before) and in that case there are no tables to clear. We think that should be a supported scenario, maybe with a flag to avoid people from accidentally not clearing the tables (e.g. bool allowNoTables=false).

@jbogard
Copy link
Owner

jbogard commented Jul 17, 2023

So why not call Respawn after you set up the database? This sounds like something wonky in your test setup.

The reason this was put in was because people were messing up their test setups and not realizing it because Respawn still ran successfully, then wondered why their database still had data even though it ran "successfully".

@chrischu
Copy link

I understand the reasoning completely, for 99% of the users the behavior is correct probably. However, would it one of the following two options be acceptable (we would of course be willing to create pull request)?

  • Add an optional bool flag (e.g. allowNoTables) to Respawner.CreateAsync (or maybe to the RespawnerOptions?)
  • Throw a more specific exception (other than InvalidOperationException) so we can just catch and ignore that

If you could tell us which option you'd prefer we will submit a pull request implementing it.

Thanks in advance!

@jbogard
Copy link
Owner

jbogard commented Jul 19, 2023

Option 3 is to fix the behavior in your tests, what's wrong with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants