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

Add a new function to delete data after each test case #109

Open
cheonglam opened this issue Nov 10, 2021 · 1 comment
Open

Add a new function to delete data after each test case #109

cheonglam opened this issue Nov 10, 2021 · 1 comment

Comments

@cheonglam
Copy link

Like

fixtures.Delete(), which will clean all the tables

Now, koad a fixtures with null yaml file will lead to "testfixtures: fixture is not a slice or map" error

I want a delegate method to clear the database

@take
Copy link

take commented Nov 12, 2021

This might be possible by using the code below:

// Delete existing table data for specified fixtures before populating the data. This helps avoid
// DELETE CASCADE constraints when using the `UseAlterConstraint()` option.
for _, file := range l.fixturesFiles {
modified := modifiedTables[file.fileNameWithoutExtension()]
if !modified {
continue
}
if err := file.delete(tx, l.helper); err != nil {
return err
}
}

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

2 participants