Skip to content
Merged
Changes from all 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
35 changes: 35 additions & 0 deletions tests/Temporalio.Tests/Worker/NexusWorkerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ namespace Temporalio.Tests.Worker;
using NexusRpc;
using NexusRpc.Handlers;
using Temporalio.Api.Enums.V1;
using Temporalio.Api.History.V1;
using Temporalio.Client;
using Temporalio.Converters;
using Temporalio.Exceptions;
using Temporalio.Nexus;
using Temporalio.Worker;
Expand Down Expand Up @@ -302,6 +304,39 @@ await Workflow.CreateNexusClient<IStringService>(endpoint).
Assert.Equal("timed out", ctx.CancellationReason);
}

[Fact]
public async Task ExecuteNexusOperationAsync_OperationSummary_FoundInHistory()
{
string expectedSummary = "custom operation summary";

var workerOptions = new TemporalWorkerOptions($"tq-{Guid.NewGuid()}").
AddNexusService(new HandlerFactoryStringService(() =>
OperationHandler.Sync<string, string>(async (ctx, name) => name)));
var endpoint = await CreateNexusEndpointAsync(workerOptions.TaskQueue!);

var handle = await RunInWorkflowAsync(workerOptions, async () =>
{
await Workflow.CreateNexusClient<IStringService>(endpoint).
ExecuteNexusOperationAsync(
svc => svc.DoSomething("some-name"),
new() { Summary = expectedSummary });
});

HistoryEvent? nexusOperationScheduledEvent = null;
await foreach (HistoryEvent historyEvent in handle.FetchHistoryEventsAsync())
{
if (historyEvent.NexusOperationScheduledEventAttributes is not null)
{
nexusOperationScheduledEvent = historyEvent;
}
}

Assert.NotNull(nexusOperationScheduledEvent);
string actualSummary = Client.Options.DataConverter.PayloadConverter.ToValue<string>(
nexusOperationScheduledEvent.UserMetadata.Summary);
Assert.Equal(expectedSummary, actualSummary);
}

[Workflow]
public class WaitForSignalWorkflow
{
Expand Down
Loading