-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fixed the filtering of duplicate columns #6543
Conversation
6bb4821
to
4a98a40
Compare
@@ -757,5 +757,14 @@ abstract class EntitiesRepositoryTest { | |||
savedEntities = repository.getEntities("things") | |||
assertThat(savedEntities[0].properties.size, equalTo(1)) | |||
assertThat(savedEntities[0].properties[0].first, equalTo("prop")) | |||
|
|||
/** | |||
* Attempt to save again to ensure that duplicate properties are correctly compared, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can break this into two test now as it feels like we're accounting for two distinct (but very related cases):
- When an entity is created with duplicate case-insensitive properties
- When an entity is created with a new property that's a case-insensitive duplicate of an existing one.
So basically we can have one test that just checks saving something like:
val entity = Entity.New(
"1",
"One",
properties = listOf(Pair("prop", "value"), Pair("Prop", "value"))
)
And another that checks saving a new entity to an existing list with a case-insensitive duplicate property like:
val repository = buildSubject()
val entity = Entity.New(
"1",
"One",
properties = listOf(Pair("prop", "value"))
)
repository.save("things", entity)
var savedEntities = repository.getEntities("things")
assertThat(savedEntities[0].properties.size, equalTo(1))
assertThat(savedEntities[0].properties[0].first, equalTo("prop"))
repository.save("things", entity.copy(properties = listOf(Pair("Prop", "value"))))
savedEntities = repository.getEntities("things")
assertThat(savedEntities[0].properties.size, equalTo(1))
assertThat(savedEntities[0].properties[0].first, equalTo("prop"))
I'm pretty sure that'll drive out both the distintBy
and the filterNot
processing we have to do and give us different fails if one or the other is missing. Mainly though, I think it'll make it easier to understand the intended behaviour from the tests.
Fixed the filtering of duplicate columns
Tested with Success Verified on device with Android 15 Verified cases:
|
Tested with Success Verified on device with Android 10 |
Why is this the best possible solution? Were any other approaches considered?
It turns out that properties might come in different order causing the problem that my tests didn't take into account, see:
https://github.com/getodk/collect/pull/6543/files#diff-c1535b2e1da246141cdc344e2d23e0ec8897df03e4055fd171a82a64cd0907a4R762
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Just continue testing that yu started in #6538.
Do we need any specific form for testing your changes? If so, please attach one.
No.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest
(or./gradlew testLab
) and confirmed all checks still passDateFormatsTest