Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ private static bool TryParseWorkflowResult(string? serializedOutput, [NotNullWhe
}

// WorkflowOutputEvent
string sourceId = root.GetProperty("sourceId").GetString() ?? string.Empty;
string outputExecutorId = root.GetProperty("executorId").GetString() ?? string.Empty;
Comment thread
kshyju marked this conversation as resolved.
Outdated
object? outputData = GetDataProperty(root);
return new WorkflowOutputEvent(outputData!, sourceId);
return new WorkflowOutputEvent(outputData!, outputExecutorId);
Comment thread
kshyju marked this conversation as resolved.
}

return JsonSerializer.Deserialize(json, eventType, DurableSerialization.Options) as WorkflowEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,35 @@ public async Task WatchStreamAsync_CompletedWithEventsInOutput_YieldsEventsAndCo
Assert.Equal("result", completedResult.Result);
}

[Fact]
public async Task WatchStreamAsync_WorkflowOutputEvent_RoundTripsCorrectlyAsync()
{
// Arrange
WorkflowOutputEvent outputEvent = new("test-data", "executor-1");
string serializedEvent = SerializeEvent(outputEvent);
string serializedOutput = SerializeWorkflowResult("done", [serializedEvent]);

Mock<DurableTaskClient> mockClient = new("test");
mockClient.Setup(c => c.GetInstanceAsync(InstanceId, true, It.IsAny<CancellationToken>()))
.ReturnsAsync(CreateMetadata(OrchestrationRuntimeStatus.Completed, serializedOutput: serializedOutput));

DurableStreamingWorkflowRun run = new(mockClient.Object, InstanceId, CreateTestWorkflow());

// Act
List<WorkflowEvent> events = [];
await foreach (WorkflowEvent evt in run.WatchStreamAsync())
{
events.Add(evt);
}

// Assert
Assert.Equal(2, events.Count);
WorkflowOutputEvent result = Assert.IsType<WorkflowOutputEvent>(events[0]);
Assert.Equal("executor-1", result.ExecutorId);
Assert.Equal("test-data", result.Data?.ToString());
Assert.Empty(result.Tags);
}
Comment thread
kshyju marked this conversation as resolved.

[Fact]
public async Task WatchStreamAsync_CompletedWithoutWrapper_YieldsFailedEventAsync()
{
Expand Down
Loading