Skip to content

Commit 4c6ad3b

Browse files
committed
More comprehensive test of tags with all triggering functions
1 parent 144db6c commit 4c6ad3b

File tree

1 file changed

+45
-2
lines changed
  • references/v3-catalog/src/trigger

1 file changed

+45
-2
lines changed

references/v3-catalog/src/trigger/tags.ts

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { RunTags } from "@trigger.dev/core/v3";
2-
import { logger, runs, tags, task } from "@trigger.dev/sdk/v3";
2+
import { logger, runs, tags, task, tasks } from "@trigger.dev/sdk/v3";
33
import { simpleChildTask } from "./subtasks";
44

55
type Payload = {
@@ -10,10 +10,53 @@ export const triggerRunsWithTags = task({
1010
id: "trigger-runs-with-tags",
1111
run: async (payload: Payload, { ctx }) => {
1212
const { id } = await simpleChildTask.trigger(
13-
{ message: "Hello from triggerRunsWithTags" },
13+
{ message: "trigger from triggerRunsWithTags" },
1414
{ tags: payload.tags }
1515
);
1616

17+
await simpleChildTask.triggerAndWait(
18+
{ message: "triggerAndWait from triggerRunsWithTags" },
19+
{ tags: payload.tags }
20+
);
21+
22+
await simpleChildTask.batchTrigger([
23+
{
24+
payload: { message: "batchTrigger 1 from triggerRunsWithTags" },
25+
options: { tags: payload.tags },
26+
},
27+
{
28+
payload: { message: "batchTrigger 2 from triggerRunsWithTags" },
29+
options: { tags: payload.tags },
30+
},
31+
]);
32+
33+
const results = await simpleChildTask.batchTriggerAndWait([
34+
{
35+
payload: { message: "batchTriggerAndWait 1 from triggerRunsWithTags" },
36+
options: { tags: payload.tags },
37+
},
38+
{
39+
payload: { message: "batchTriggerAndWait 2 from triggerRunsWithTags" },
40+
options: { tags: payload.tags },
41+
},
42+
]);
43+
44+
await tasks.trigger<typeof simpleChildTask>(
45+
"simple-child-task",
46+
{ message: "tasks.trigger from triggerRunsWithTags" },
47+
{ tags: payload.tags }
48+
);
49+
await tasks.batchTrigger<typeof simpleChildTask>("simple-child-task", [
50+
{
51+
payload: { message: "tasks.batchTrigger 1 from triggerRunsWithTags" },
52+
options: { tags: payload.tags },
53+
},
54+
{
55+
payload: { message: "tasks.batchTrigger 2 from triggerRunsWithTags" },
56+
options: { tags: payload.tags },
57+
},
58+
]);
59+
1760
const run = await runs.retrieve(id);
1861
logger.log("run", run);
1962

0 commit comments

Comments
 (0)