Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Fix #42 flowOf doesn't respect the passed key. #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Kasheen
Copy link

@Kasheen Kasheen commented Aug 26, 2021

Summary
This Pull Request fixes #42.

It also adds flowOf tests to DBTests_04_Flows.kt.

Notes
I noticed something strange when writing the tests.

For some reason keyById (and by extension the stateFlowOfId tests) require the id varargs to be passed as keyById("Salomon", "BRYS") instead of the way they are defined in the Person model, which is override val id get() = listOf(lastName, firstName)

I'm not sure if this is a bug. I think it's following the declaration order of the data class. I've changed the test for stateFlow, this issue was hidden before because the key wasn't being compared by the listener, but the keys being generated in the listener's operation were different from what was being generated for the parameters passed to stateFlowOfId.

I'm happy to write some docs for flowOf if you wish, but I noticed that the docs on master are ahead of the docs on the website, so these flows weren't as undocumented as I thought, infact they are quite well documented!

Add flowOf tests to DBTests_04_Flows.
@Kasheen
Copy link
Author

Kasheen commented Aug 27, 2021

I've realised what's wrong with the keyOfId stuff in the tests. I had followed the other existing tests (test00_operationFlow) to construct the Adult but I think the Adult is constructed wrongly in the other tests, "BRYS" is being filled in as the first name and "Saloman" is being filled in as the last name, hence having to send those parameters to the keyOfId backwards.

Fix the parameter order of the models used in the flow tests.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flowOf doesn't respect the passed key.
1 participant