Skip to content

Commit 23e8d37

Browse files
committed
fix worker group tests
1 parent e155aad commit 23e8d37

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

apps/webapp/test/workerGroup.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { HEADER_NAME } from "@trigger.dev/worker";
1919
import { RunEngine } from "@internal/run-engine";
2020
import { trace } from "@opentelemetry/api";
2121
import { TriggerTaskService } from "~/v3/services/triggerTask.server";
22+
import { env } from "~/env.server";
2223

2324
describe("worker", () => {
2425
const defaultInstanceName = "test_worker";
@@ -69,6 +70,7 @@ describe("worker", () => {
6970
headers: {
7071
Authorization: `Bearer ${token.plaintext}`,
7172
[HEADER_NAME.WORKER_INSTANCE_NAME]: defaultInstanceName,
73+
[HEADER_NAME.WORKER_MANAGED_SECRET]: env.MANAGED_WORKER_SECRET,
7274
},
7375
});
7476

@@ -86,6 +88,7 @@ describe("worker", () => {
8688
headers: {
8789
Authorization: `Bearer ${token.plaintext}`,
8890
[HEADER_NAME.WORKER_INSTANCE_NAME]: secondInstanceName,
91+
[HEADER_NAME.WORKER_MANAGED_SECRET]: env.MANAGED_WORKER_SECRET,
8992
},
9093
});
9194
const secondAuth = await tokenService.authenticate(secondRequest);
@@ -99,7 +102,11 @@ describe("worker", () => {
99102
containerTest("dequeue - unmanaged", async ({ prisma, redisContainer }) => {
100103
const taskIdentifier = "test-task";
101104

102-
const authenticatedEnvironment = await setupAuthenticatedEnvironment(prisma, "PRODUCTION");
105+
const authenticatedEnvironment = await setupAuthenticatedEnvironment(
106+
prisma,
107+
"PRODUCTION",
108+
"V2"
109+
);
103110

104111
const { deployment } = await setupBackgroundWorker(
105112
prisma,
@@ -136,7 +143,7 @@ describe("worker", () => {
136143
const tokenService = new WorkerGroupTokenService({ prisma, engine });
137144
const authenticatedInstance = await tokenService.authenticate(request);
138145

139-
assert(authenticatedInstance, "authenticationInstance should be defined");
146+
assert(authenticatedInstance, "authenticatedInstance should be defined");
140147
expect(authenticatedInstance.type).toBe(WorkerInstanceGroupType.UNMANAGED);
141148
assert(
142149
authenticatedInstance.type === WorkerInstanceGroupType.UNMANAGED,

internal-packages/testcontainers/src/setup.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
BackgroundWorkerTask,
99
Prisma,
1010
PrismaClient,
11+
RunEngineVersion,
1112
RuntimeEnvironmentType,
1213
} from "@trigger.dev/database";
1314

@@ -17,7 +18,8 @@ export type AuthenticatedEnvironment = Prisma.RuntimeEnvironmentGetPayload<{
1718

1819
export async function setupAuthenticatedEnvironment(
1920
prisma: PrismaClient,
20-
type: RuntimeEnvironmentType
21+
type: RuntimeEnvironmentType,
22+
engine?: RunEngineVersion
2123
) {
2224
// Your database setup logic here
2325
const org = await prisma.organization.create({
@@ -33,6 +35,7 @@ export async function setupAuthenticatedEnvironment(
3335
slug: "test-project",
3436
externalRef: "proj_1234",
3537
organizationId: org.id,
38+
engine,
3639
},
3740
});
3841

0 commit comments

Comments
 (0)