Skip to content

Commit cdbfc39

Browse files
committed
Add test
1 parent 8eaa932 commit cdbfc39

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

src/WorkerVersioning/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static async Task Main(string[] args)
4949
}
5050
}
5151

52-
private static async Task RunDemoAsync(TemporalClient client)
52+
public static async Task RunDemoAsync(TemporalClient client)
5353
{
5454
// Wait for v1 worker and set as current version
5555
var workerV1Version = new WorkerDeploymentVersion(Program.DeploymentName, "1.0");

tests/TemporalioSamples.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<ProjectReference Include="..\src\UpdateWithStartLazyInit\TemporalioSamples.UpdateWithStartLazyInit.csproj" />
3232
<ProjectReference Include="..\src\WorkerSpecificTaskQueues\TemporalioSamples.WorkerSpecificTaskQueues.csproj" />
3333
<ProjectReference Include="..\src\WorkflowUpdate\TemporalioSamples.WorkflowUpdate.csproj" />
34+
<ProjectReference Include="..\src\WorkerVersioning\TemporalioSamples.WorkerVersioning.csproj" />
3435
<ProjectReference Include="..\src\SleepForDays\TemporalioSamples.SleepForDays.csproj" />
3536
</ItemGroup>
3637

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
namespace TemporalioSamples.Tests.WorkerVersioning;
2+
3+
using Temporalio.Client;
4+
using TemporalioSamples.WorkerVersioning;
5+
using Xunit;
6+
using Xunit.Abstractions;
7+
8+
public class WorkerVersioningTests : WorkflowEnvironmentTestBase
9+
{
10+
public WorkerVersioningTests(ITestOutputHelper output, WorkflowEnvironment env)
11+
: base(output, env)
12+
{
13+
}
14+
15+
[Fact]
16+
public async Task WorkerVersioningSampleCanRun()
17+
{
18+
var temporalClient = new TemporalClient(Client.Connection, Client.Options);
19+
20+
using var cts = new CancellationTokenSource();
21+
22+
var workerV1Task = Task.Run(() => WorkerV1.RunAsync(Client, cts.Token));
23+
var workerV1_1Task = Task.Run(() => WorkerV1Dot1.RunAsync(Client, cts.Token));
24+
var workerV2Task = Task.Run(() => WorkerV2.RunAsync(Client, cts.Token));
25+
26+
try
27+
{
28+
await Program.RunDemoAsync(temporalClient);
29+
Assert.True(true, "Worker versioning demo completed successfully");
30+
}
31+
finally
32+
{
33+
await cts.CancelAsync();
34+
35+
try
36+
{
37+
await Task.WhenAll(workerV1Task, workerV1_1Task, workerV2Task);
38+
}
39+
catch (OperationCanceledException)
40+
{
41+
}
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)