-
Notifications
You must be signed in to change notification settings - Fork 102
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
Add testRender with CoroutineScope for SessionWorkflow #1141
Conversation
a4dca45
to
ada7b66
Compare
@Suppress("UNCHECKED_CAST") | ||
public fun <PropsT, OutputT, RenderingT> Workflow<PropsT, OutputT, RenderingT>.testRender( | ||
props: PropsT | ||
): RenderTester<PropsT, *, OutputT, RenderingT> { | ||
val statefulWorkflow = asStatefulWorkflow() as StatefulWorkflow<PropsT, Any?, OutputT, RenderingT> | ||
return statefulWorkflow.testRender( | ||
props = props, | ||
initialState = statefulWorkflow.initialState(props, null) | ||
initialState = run { | ||
require(this !is SessionWorkflow<PropsT, *, OutputT, RenderingT>) { |
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.
nice
*/ | ||
@OptIn(WorkflowExperimentalApi::class) | ||
@Suppress("UNCHECKED_CAST") | ||
public fun <PropsT, OutputT, RenderingT> Workflow<PropsT, OutputT, RenderingT>.testRender( |
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.
Can't you make this version an extension on SessionWorkflow
and avoid the runtime check?
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.
ya I thought about that but then I thought about how in your tests you might not have the reified SessionWorkflow
type? Maybe you were passing it around or dealign with it just as a Workflow
? Maybe I was overthinking it though. Perhaps we could just make it an extension on SessionWorkflow
🤔
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 so. I'm going to write a unit test against class RealFooWorkflow
, not interface FooWorkflow
.
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.
ya, I think you are right. I will change it.
- testRender + CoroutineScope extension extends
SessionWorkflow
notWorkflow
f756591
to
4bf0412
Compare
9155c85
to
1a34138
Compare
1a34138
to
c43729f
Compare
Fixes #1138