fix(test): add VaultService dependencies to job-events performance test
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Add ConfigService mock for encryption configuration - Add VaultService and CryptoService to test module - Fixes: PrismaService dependency injection error in test PrismaService requires VaultService for credential encryption. Performance tests now properly provide all required dependencies. Refs #341 (pipeline test failure)
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
import { describe, it, expect, beforeAll, afterAll } from "vitest";
|
import { describe, it, expect, beforeAll, afterAll, vi } from "vitest";
|
||||||
import { Test, TestingModule } from "@nestjs/testing";
|
import { Test, TestingModule } from "@nestjs/testing";
|
||||||
|
import { ConfigService } from "@nestjs/config";
|
||||||
import { JobEventsService } from "./job-events.service";
|
import { JobEventsService } from "./job-events.service";
|
||||||
import { PrismaService } from "../prisma/prisma.service";
|
import { PrismaService } from "../prisma/prisma.service";
|
||||||
|
import { VaultService } from "../vault/vault.service";
|
||||||
|
import { CryptoService } from "../federation/crypto.service";
|
||||||
import { JOB_CREATED, JOB_STARTED, STEP_STARTED } from "./event-types";
|
import { JOB_CREATED, JOB_STARTED, STEP_STARTED } from "./event-types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,8 +25,30 @@ describeFn("JobEventsService Performance", () => {
|
|||||||
let testWorkspaceId: string;
|
let testWorkspaceId: string;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
// Mock ConfigService for VaultService/CryptoService
|
||||||
|
const mockConfigService = {
|
||||||
|
get: vi.fn((key: string) => {
|
||||||
|
const config: Record<string, string> = {
|
||||||
|
ENCRYPTION_KEY: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
|
||||||
|
OPENBAO_ADDR: "http://localhost:8200",
|
||||||
|
OPENBAO_ROLE_ID: "test-role-id",
|
||||||
|
OPENBAO_SECRET_ID: "test-secret-id",
|
||||||
|
};
|
||||||
|
return config[key] || null;
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [JobEventsService, PrismaService],
|
providers: [
|
||||||
|
JobEventsService,
|
||||||
|
PrismaService,
|
||||||
|
{
|
||||||
|
provide: ConfigService,
|
||||||
|
useValue: mockConfigService,
|
||||||
|
},
|
||||||
|
VaultService,
|
||||||
|
CryptoService,
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<JobEventsService>(JobEventsService);
|
service = module.get<JobEventsService>(JobEventsService);
|
||||||
|
|||||||
Reference in New Issue
Block a user