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

fix test that fails depending on run order #306

Merged
merged 2 commits into from
Dec 14, 2023
Merged

Conversation

giovanni-guidini
Copy link
Contributor

@giovanni-guidini giovanni-guidini commented Dec 13, 2023

If you run

pytest \
 graphql_api/tests/test_impacted_file.py::TestImpactedFileFiltering::test_filtering_with_successful_flags \
 compare/commands/compare/interactors/tests/test_fetch_impacted_files.py::FetchImpactedFilesTest::test_impacted_files_filtered_by_flags_and_commit_comparison_for_pull

you'll see the 2nd test fails.

This is because of the PullID that apparently both tests create a pullID of 1.
It is strange because they are TransactionTestCase and that's supposed to reset the DB,
but God knowns what is going on.

Hard setting the pullID to different numbers solves the issue, but I'll be the 1st
to admit is not a pretty fix

If you run
```
pytest \
 graphql_api/tests/test_impacted_file.py::TestImpactedFileFiltering::test_filtering_with_successful_flags \
 compare/commands/compare/interactors/tests/test_fetch_impacted_files.py::FetchImpactedFilesTest::test_impacted_files_filtered_by_flags_and_commit_comparison_for_pull
```

you'll see the 2nd test fails.

This is because of the PullID that apparently both tests create a pullID of 1.
It is strange because they are `TransactionTestCase` and that's supposed to reset the DB,
but God knowns what is going on.

Hard setting the pullID to different numbers solves the issue, but I'll be the 1st
to admit is not a pretty fix
@codecov-qa
Copy link

codecov-qa bot commented Dec 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (df9ebfd) 95.95% compared to head (4bdacb7) 95.95%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #306   +/-   ##
=======================================
  Coverage   95.95%   95.95%           
=======================================
  Files         611      611           
  Lines       15719    15719           
=======================================
  Hits        15083    15083           
  Misses        636      636           
Flag Coverage Δ
unit 95.95% <ø> (ø)
unit-latest-uploader 95.95% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codecov-public-qa bot commented Dec 13, 2023

Codecov Report

Merging #306 (4bdacb7) into main (df9ebfd) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #306   +/-   ##
=======================================
  Coverage   95.95%   95.95%           
=======================================
  Files         611      611           
  Lines       15719    15719           
=======================================
  Hits        15083    15083           
  Misses        636      636           
Flag Coverage Δ
unit 95.95% <ø> (ø)
unit-latest-uploader 95.95% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted file tree graph

@@ -590,6 +590,7 @@ def test_impacted_files_filtered_by_flags_and_commit_comparison_for_pull(
CommitFactory(repository=repo),
)
pull = PullFactory(
pullid=256,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Does this mean setting to any ID less than 256 would not work?
  • If you add a test (that creates a Pull object in the DB) that runs before this one, does that mean this would fail? Since the next available unused ID is 257?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean setting to any ID less than 256 would not work?

No, it's just a random number.

If you add a test (that creates a Pull object in the DB) that runs before this one, ...

well the other test I mentioned that causes this issue creates another pull object in the database with ID 44. So, no?

Where did you get that the next available ID is 257?...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok I didn't know it was a random number, I though anything below 256 is used.

Copy link

codecov bot commented Dec 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (df9ebfd) 95.57% compared to head (8a80532) 95.56%.

❗ Current head 8a80532 differs from pull request most recent head 4bdacb7. Consider uploading reports for the commit 4bdacb7 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #306     +/-   ##
=======================================
- Coverage   95.57   95.56   -0.01     
=======================================
  Files        726     726             
  Lines      16228   16178     -50     
=======================================
- Hits       15509   15459     -50     
  Misses       719     719             
Flag Coverage Δ
unit ?
unit-latest-uploader ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@giovanni-guidini giovanni-guidini merged commit cd33523 into main Dec 14, 2023
17 checks passed
@giovanni-guidini giovanni-guidini deleted the gio/fix-test branch December 14, 2023 15:07
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.

None yet

2 participants