-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Test exact array contents where possible #3731
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
houndci-bot
reviewed
Sep 26, 2019
javierm
force-pushed
the
array_specs
branch
2 times, most recently
from
September 26, 2019 19:15
e4ad68d
to
66d0fb9
Compare
houndci-bot
reviewed
Sep 26, 2019
javierm
force-pushed
the
array_specs
branch
from
September 26, 2019 21:06
b75f300
to
a74b6da
Compare
houndci-bot
reviewed
Sep 26, 2019
javierm
force-pushed
the
array_specs
branch
2 times, most recently
from
September 27, 2019 18:13
81da7d7
to
144f290
Compare
javierm
force-pushed
the
remove_obsolete_code
branch
from
September 27, 2019 19:58
d3c5a76
to
d79d840
Compare
javierm
force-pushed
the
array_specs
branch
4 times, most recently
from
September 28, 2019 03:38
f7fec4c
to
0bfe3b4
Compare
javierm
force-pushed
the
remove_obsolete_code
branch
from
September 28, 2019 12:27
4b64487
to
7373e83
Compare
javierm
force-pushed
the
array_specs
branch
5 times, most recently
from
September 29, 2019 13:54
ba73617
to
90195da
Compare
javierm
force-pushed
the
remove_obsolete_code
branch
from
September 29, 2019 14:07
d0e5157
to
357bf5f
Compare
javierm
force-pushed
the
array_specs
branch
from
September 29, 2019 14:07
90195da
to
0f401a3
Compare
javierm
force-pushed
the
remove_obsolete_code
branch
2 times, most recently
from
September 29, 2019 20:53
82aa8db
to
f426b25
Compare
Instead of testing the contents of each element, we can test the whole array at once.
It's shorter, and easy to read.
javierm
force-pushed
the
array_specs
branch
from
September 29, 2019 21:25
0f401a3
to
d93fd65
Compare
javierm
force-pushed
the
array_specs
branch
from
September 29, 2019 21:33
d93fd65
to
f9255d2
Compare
We were using `to_sentence` to check the order, while it's easier to just check the exact contents of the array. Furthermore, using `to_sentence` checked the order of the array, so it was a potentially flaky spec since the method doesn't specify an order and PostgreSQL doesn't guarantee the order of the records.
The test or the draft phase legislation filter was using an entirely different set of records, but was still creating the records used in the open and past filter as well. This made it hard to test the filter, since it returned records from both sets. Grouping the past and open filters together guarantees their records won't be created in the phase draft test, and so we can test the exact contents of the array.
We're using `eq` and `match_array` in most places, but there were a few places where we were still checking each element is included in the array. This is a bit dangerous, because the array could have duplicate elements, and we wouldn't detect them with `include`.
Using `not_to include` does not test for other elements which could be present in the array.
When we already have tests checking which records are included, in the tests testing records are not included we can just generate records which will not be included and test against an empty array. We were already using this approach in some tests. This way we also avoid useless assignments.
javierm
force-pushed
the
array_specs
branch
from
September 29, 2019 21:57
f9255d2
to
c2d7420
Compare
smarques
pushed a commit
to venetochevogliamo/consul
that referenced
this pull request
Apr 29, 2020
Test exact array contents where possible
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
References
Objectives