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

spec: don't clear database automatically #165

Merged
merged 1 commit into from
Mar 27, 2018

Conversation

maiha
Copy link
Contributor

@maiha maiha commented Mar 27, 2018

In current specs, every time we run one test case, we initialize 33 tables with 3 adapters in total.

# pseudo code
Spec.before_each do
  adapters.each do |adapter| # 3 times
    adapter::table1.clear    # 11 tables in total
    ...

This is expensive to run and is unnecessary work for most test cases. Therefore, execution of all tests is very slow and this cost will continue to increase each time additional functionality is added.

In this PR, I propose a policy to delete tables manually rather than automatically. When writing a test, we do not assume that the table is empty, we need to manually run the table as needed.

Benchmark

In my environment.

master
  • 8m13s (with 6118 DB operations)
PR
  • 43s (with 1012 DB operations)

FYI: This is a commits dependency for natural-key in my fork.

  1. add spec for callbacks #154 add spec for callbacks (merged) 🎉
  2. spec: don't clear database automatically #165 spec: don't clear database automatically (This PR)
  3. add record statuses about persistence: new_record?, destroyed?, persisted? #153 add record statuses about persistence
  4. Set the primary key to a new record #143 primary auto: false works as a natural key

Best regards,

@drujensen drujensen merged commit 43fc6fc into amberframework:master Mar 27, 2018
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

Successfully merging this pull request may close these issues.

2 participants