Can Turbine help me test a Flow without caring about the order of events? #197
-
Sometimes, I have a Flow that might emit several events. I don't know what order these events will come in, or how many events there will be, but I need to verify that at least one of them satisfies a certain condition. In these situations I find myself writing code that looks like this:
It would be nice if this could be condensed to something like:
Where Can Turbine do that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There is nothing built in, but you could definitely write an extension which did this. Simply loop on For such a function to be included in Turbine itself there's all kinds of considerations to be made. For example:
I think including such a function starts to move Turbine from being a fairly simple collector of events from a One thing that might be useful is to provide more access to events which are already consumed. This would result in changing from a channel as the sole backing primitive to some other type that I suspect we need to build ourselves. But, again, I'm hesitant to make that change unless we absolutely need it. |
Beta Was this translation helpful? Give feedback.
There is nothing built in, but you could definitely write an extension which did this. Simply loop on
awaitItem()
until your condition is met and then break.For such a function to be included in Turbine itself there's all kinds of considerations to be made. For example:
I think including such a function starts to move Turbine from being a fairly simple collector of events from a
Flow
and into an actual library providing assertions over a st…