iZettle / Flow

Flow is a Swift library for working with asynchronous flows and life cycles
MIT License
231 stars 14 forks source link

Add tests for 'flatMapError' #77

Closed skye-pp closed 5 years ago

skye-pp commented 5 years ago

What

We were using flatMapError in iZettle Pro and were having trouble understanding the intricacies of what errors get mapped and when.

To better understand it, I wrote some unit tests which do some "fake work" (a very small delay) and assert the values and errors are as we expect after transformation in flatMapError.

I've used assertForOverFulfill because we thought we might be seeing some odd behaviour around double firing of mapped values - if both error and value happen, the tests will fail.

Quite happy to make changes if you'd like, just let me know.

Why

To document and verify the expected behaviour of flatMapError.

mansbernhardt commented 5 years ago

Great to see more tests added to Flow!

So, I'm curious, did flatMapError behave as you expected? Do you think the documentation needs to be improved to better understand its behavior?

skye-pp commented 5 years ago

It did behave as we expected, and we had a bug elsewhere 👍

In terms of documentation - with the context of these tests, the comment makes sense to me, but I've gotten used to searching in the tests for usage examples, so I didn't get it the first time around. I think the comment on the function is fine, it just needed backed up with a usage example.