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

Unit test touching the database #212

Open
rafamanzo opened this issue Jul 15, 2016 · 1 comment
Open

Unit test touching the database #212

rafamanzo opened this issue Jul 15, 2016 · 1 comment

Comments

@rafamanzo
Copy link
Member

rafamanzo commented Jul 15, 2016

While developing #211 I ran into an special seed for our unit tests. By running ruby performance/tests/aggregation.rb && rspec --seed 20271 from that branch:

KalibroModuleLongNameValidator methods validate within a different processing and with the same granularity and the same long name is expected to NOT add any errors
     Failure/Error: same_name.save
     ActiveRecord::RecordNotUnique:
       PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "processings_pkey"
       DETAIL:  Key (id)=(1) already exists.
       : INSERT INTO "processings" ("created_at", "updated_at", "state", "root_module_result_id", "id") VALUES ($1, $2, $3, $4, $5) RETURNING "id"

Running just rspec --seed 20271 does not produce the error. On the other hand, the first script runs DatabaseCleaner before and after running, so the database should be left clean after the first script.

So we need to investigate deeper wether the first script is leaving the database dirty or is leaving the ids sequence in some special state that produces the test error or even if the unit test itself is touching the database unnecessarily.

@danielkza
Copy link
Contributor

This was a case of hardcoded IDs I believe. I think I have it fixed on my DB fixes branch - I'll make a PR for it soon.

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

No branches or pull requests

2 participants