Skip to content

Commit

Permalink
Add Tests for WorkflowTracer
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-the-edwards committed Dec 6, 2024
1 parent b2e9f1e commit 18312f1
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal class WorkerWorkflow<OutputT>(
ImpostorWorkflow {

override val realIdentifier: WorkflowIdentifier =
workflowTracer.trace("ComputeRealIdentifier" ) {
workflowTracer.trace("ComputeRealIdentifier") {
unsnapshottableIdentifier(workerType)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ internal class SubtreeManager<PropsT, StateT, OutputT>(
// Prevent duplicate workflows with the same key.
workflowTracer.trace("CheckingUniqueMatches") {
children.forEachStaging {
require(!(it.matches(child, key))) {
require(!(it.matches(child, key, workflowTracer))) {
"Expected keys to be unique for ${child.identifier}: key=\"$key\""
}
}
Expand All @@ -136,7 +136,7 @@ internal class SubtreeManager<PropsT, StateT, OutputT>(
val stagedChild =
workflowTracer.trace("RetainingChildren") {
children.retainOrCreate(
predicate = { it.matches(child, key) },
predicate = { it.matches(child, key, workflowTracer) },
create = { createChildNode(child, props, key, handler) }
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.squareup.workflow1.internal
import com.squareup.workflow1.StatefulWorkflow
import com.squareup.workflow1.Workflow
import com.squareup.workflow1.WorkflowAction
import com.squareup.workflow1.WorkflowTracer
import com.squareup.workflow1.internal.InlineLinkedList.InlineListNode
import com.squareup.workflow1.trace

/**
* Representation of a child workflow that has been rendered by another workflow.
Expand Down Expand Up @@ -32,8 +34,9 @@ internal class WorkflowChildNode<
*/
fun matches(
otherWorkflow: Workflow<*, *, *>,
key: String
): Boolean = id.matches(otherWorkflow, key)
key: String,
workflowTracer: WorkflowTracer?
): Boolean = workflowTracer.trace("matches") { id.matches(otherWorkflow, key) }

/**
* Updates the handler function that will be invoked by [acceptChildOutput].
Expand Down
Loading

0 comments on commit 18312f1

Please sign in to comment.