Skip to content

Commit 781a620

Browse files
committed
minor updates
improve workflow unit test Signed-off-by: kaibocai <[email protected]>
1 parent 3a2649f commit 781a620

19 files changed

+499
-428
lines changed

package-lock.json

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"test:e2e:common": "npm run test:e2e:common:client && npm run test:e2e:common:server",
2121
"test:e2e:common:client": "./scripts/test-e2e-common.sh client",
2222
"test:e2e:common:server": "./scripts/test-e2e-common.sh server",
23-
"test:e2e:workflow": "npm run prebuild && TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id workflow-test-suite --app-protocol grpc --dapr-grpc-port 4001 --components-path ./test/components/workflow -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/workflow/workflow.test.ts' ]",
23+
"test:e2e:workflow": "npm run prebuild && dapr run --app-id workflow-test-suite --app-protocol grpc --dapr-grpc-port 4001 --components-path ./test/components/workflow -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/workflow/workflow.test.ts' ]",
2424
"test:e2e:workflow:internal": "jest test/e2e/workflow --runInBand --detectOpenHandles",
2525
"test:e2e:workflow:durabletask": "./scripts/test-e2e-workflow.sh",
2626
"test:unit": "jest --runInBand --detectOpenHandles",

src/workflow/types/Activity.type.ts renamed to src/types/workflow/Activity.type.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Dapr Authors
2+
Copyright 2024 The Dapr Authors
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
@@ -11,6 +11,6 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
1313

14-
import WorkflowActivityContext from "../runtime/WorkflowActivityContext";
14+
import WorkflowActivityContext from "../../workflow/runtime/WorkflowActivityContext";
1515

1616
export type TWorkflowActivity<TInput, TOutput> = (context: WorkflowActivityContext, input: TInput) => TOutput;

src/workflow/types/InputOutput.type.ts renamed to src/types/workflow/InputOutput.type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Dapr Authors
2+
Copyright 2024 The Dapr Authors
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

src/workflow/types/Workflow.type.ts renamed to src/types/workflow/Workflow.type.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Dapr Authors
2+
Copyright 2024 The Dapr Authors
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
1313

14-
import WorkflowContext from "../runtime/WorkflowContext";
14+
import WorkflowContext from "../../workflow/runtime/WorkflowContext";
1515
import { Task } from "kaibocai-durabletask-js/task/task";
1616
import { TOutput } from "./InputOutput.type";
1717

src/workflow/client/WorkflowClient.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Dapr Authors
2+
Copyright 2024 The Dapr Authors
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
@@ -15,7 +15,7 @@ import { TaskHubGrpcClient } from "kaibocai-durabletask-js";
1515
import * as grpc from "@grpc/grpc-js";
1616
import { WorkflowState } from "./WorkflowState";
1717
import { generateInterceptors } from "../internal/ApiTokenClientInterceptor";
18-
import { TWorkflow } from "../types/Workflow.type";
18+
import { TWorkflow } from "../../types/workflow/Workflow.type";
1919
import { getFunctionName } from "../internal";
2020

2121
export default class WorkflowClient {
@@ -27,10 +27,10 @@ export default class WorkflowClient {
2727
* @param {grpc.ChannelOptions | undefined} options - Additional options for configuring the gRPC channel.
2828
*/
2929
constructor(hostAddress?: string, options?: grpc.ChannelOptions) {
30-
this._innerClient = this._buildInnerClient(hostAddress, options);
30+
this._innerClient = this.buildInnerClient(hostAddress, options);
3131
}
3232

33-
_buildInnerClient(hostAddress = "127.0.0.1:50001", options: grpc.ChannelOptions = {}): TaskHubGrpcClient {
33+
private buildInnerClient(hostAddress = "127.0.0.1:50001", options: grpc.ChannelOptions = {}): TaskHubGrpcClient {
3434
const innerOptions = {
3535
...options,
3636
interceptors: [generateInterceptors(), ...(options?.interceptors ?? [])],
@@ -42,6 +42,9 @@ export default class WorkflowClient {
4242
* Schedules a new workflow using the DurableTask client.
4343
*
4444
* @param {TWorkflow | string} workflow - The Workflow or the name of the workflow to be scheduled.
45+
* @param {any} [input] - The input to be provided to the scheduled workflow.
46+
* @param {string} [instanceId] - An optional unique identifier for the workflow instance.
47+
* @param {Date} [startAt] - An optional date and time at which the workflow should start.
4548
* @return {Promise<string>} A Promise resolving to the unique ID of the scheduled workflow instance.
4649
*/
4750
public async scheduleNewWorkflow(

src/workflow/client/WorkflowFailureDetails.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Dapr Authors
2+
Copyright 2024 The Dapr Authors
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

src/workflow/client/WorkflowState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Dapr Authors
2+
Copyright 2024 The Dapr Authors
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

src/workflow/examples/activity-sequence.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Dapr Authors
2+
Copyright 2024 The Dapr Authors
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
@@ -15,7 +15,7 @@ import WorkflowClient from "../client/WorkflowClient";
1515
import WorkflowActivityContext from "../runtime/WorkflowActivityContext";
1616
import WorkflowContext from "../runtime/WorkflowContext";
1717
import WorkflowRuntime from "../runtime/WorkflowRuntime";
18-
import { TWorkflow } from "../types/Workflow.type";
18+
import { TWorkflow } from "../../types/workflow/Workflow.type";
1919

2020
(async () => {
2121
const grpcEndpoint = "localhost:4001";
@@ -31,7 +31,7 @@ import { TWorkflow } from "../types/Workflow.type";
3131

3232
const result1 = yield ctx.callActivity(hello, "Tokyo");
3333
cities.push(result1);
34-
const result2 = yield ctx.callActivity(hello, "Seattle"); // Correct the spelling of "Seattle"
34+
const result2 = yield ctx.callActivity(hello, "Seattle");
3535
cities.push(result2);
3636
const result3 = yield ctx.callActivity(hello, "London");
3737
cities.push(result3);

src/workflow/examples/fanout-fanin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Dapr Authors
2+
Copyright 2024 The Dapr Authors
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
@@ -16,7 +16,7 @@ import WorkflowClient from "../client/WorkflowClient";
1616
import WorkflowActivityContext from "../runtime/WorkflowActivityContext";
1717
import WorkflowContext from "../runtime/WorkflowContext";
1818
import WorkflowRuntime from "../runtime/WorkflowRuntime";
19-
import { TWorkflow } from "../types/Workflow.type";
19+
import { TWorkflow } from "../../types/workflow/Workflow.type";
2020

2121
// Wrap the entire code in an immediately-invoked async function
2222
(async () => {

0 commit comments

Comments
 (0)