Skip to content

Bugfix workflow execute dtmfailureexception #100

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

Merged
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/Dtmworkflow/Workflow.Imp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ internal async Task<byte[]> Process(WfFunc2 handler, byte[] data)
await this.Submit(res, err, default);
}

if (err != null)
throw err;

return res;
}

Expand Down
9 changes: 4 additions & 5 deletions tests/Dtmworkflow.Tests/WorkflowHttpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
var gid = Guid.NewGuid().ToString("N");

var handler = new Mock<WfFunc2>();
handler.Setup(x => x.Invoke(It.IsAny<Workflow>(), It.IsAny<byte[]>())).Returns(Task.FromResult<byte[]>(null));

Check warning on line 65 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on windows-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 65 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on windows-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 65 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 65 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 65 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 65 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 65 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on windows-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 65 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on windows-latest

Cannot convert null literal to non-nullable reference type.

wfgt.Register(wfName, handler.Object);

Expand Down Expand Up @@ -141,7 +141,7 @@
}

[Fact]
public async void Execute_Should_Return_Null_When_WfFunc2_ThrowDtmFailureException()
public async void Execute_Should_ThrowDtmFailureException_When_WfFunc2_ThrowDtmFailureException()
{
var factory = new Mock<IWorkflowFactory>();
var httpClient = new Mock<IDtmClient>();
Expand All @@ -161,7 +161,7 @@

var wfgt = new WorkflowGlobalTransaction(factory.Object, NullLoggerFactory.Instance);

var wfName = nameof(Execute_Should_Return_Null_When_WfFunc2_ThrowDtmFailureException);
var wfName = nameof(Execute_Should_ThrowDtmFailureException_When_WfFunc2_ThrowDtmFailureException);
var gid = Guid.NewGuid().ToString("N");

var handler = new Mock<WfFunc2>();
Expand All @@ -170,8 +170,7 @@
wfgt.Register(wfName, handler.Object);
var req = JsonSerializer.Serialize(new { userId = "1", amount = 30 });

var res = await wfgt.Execute(wfName, gid, Encoding.UTF8.GetBytes(req), true);
Assert.Null(res);
await Assert.ThrowsAsync<DtmFailureException>(async () => await wfgt.Execute(wfName, gid, Encoding.UTF8.GetBytes(req), true));
}

[Fact]
Expand Down Expand Up @@ -209,7 +208,7 @@
wfgt.Register(wfName, handler);
var req = JsonSerializer.Serialize(new { userId = "1", amount = 30 });

var res = await wfgt.Execute(wfName, gid, Encoding.UTF8.GetBytes(req), true);
var res = await Assert.ThrowsAsync<DtmFailureException>(async () => await wfgt.Execute(wfName, gid, Encoding.UTF8.GetBytes(req), true));

func.Verify(x => x.Invoke(It.IsAny<BranchBarrier>()), Times.Once);
}
Expand Down Expand Up @@ -362,7 +361,7 @@
Assert.Null(res);
}

private void SetupPrepareWorkflow(Mock<IDtmClient> httpClient, string status, string? result, List<DtmProgressDto> progressDtos = null)

Check warning on line 364 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on windows-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 364 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on windows-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 364 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 364 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 364 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 364 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 364 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on windows-latest

Cannot convert null literal to non-nullable reference type.

Check warning on line 364 in tests/Dtmworkflow.Tests/WorkflowHttpTests.cs

View workflow job for this annotation

GitHub Actions / build on windows-latest

Cannot convert null literal to non-nullable reference type.
{
var httpResp = new HttpResponseMessage(HttpStatusCode.OK);
httpResp.Content = new StringContent(JsonSerializer.Serialize(
Expand Down
Loading