test(integration): add lightweight MySQL-backed API smoke tests for center and guild
This commit is contained in:
@@ -8,13 +8,13 @@ export class AuditLog {
|
||||
@Column()
|
||||
action!: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@Column({ type: 'varchar', length: 64, nullable: true })
|
||||
actorId!: string | null;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@Column({ type: 'varchar', length: 64, nullable: true })
|
||||
targetType!: string | null;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@Column({ type: 'varchar', length: 120, nullable: true })
|
||||
targetId!: string | null;
|
||||
|
||||
@Column({ type: 'text', nullable: true })
|
||||
|
||||
40
Fabric.Backend.Center/src/health.integration.spec.ts
Normal file
40
Fabric.Backend.Center/src/health.integration.spec.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import request from 'supertest';
|
||||
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
process.env.DB_HOST = '127.0.0.1';
|
||||
process.env.DB_PORT = '3307';
|
||||
process.env.DB_USER = 'fabric';
|
||||
process.env.DB_PASSWORD = 'fabric';
|
||||
process.env.DB_NAME = 'fabric_center';
|
||||
process.env.DB_SYNC = 'false';
|
||||
process.env.CENTER_SHARED_SECRET = 'test-center-secret';
|
||||
process.env.JWT_ACCESS_SECRET = 'test-access-secret';
|
||||
process.env.JWT_REFRESH_SECRET = 'test-refresh-secret';
|
||||
|
||||
describe('center integration (mysql + api)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeAll(async () => {
|
||||
const { AppModule } = await import('./app.module');
|
||||
const moduleRef = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleRef.createNestApplication();
|
||||
app.setGlobalPrefix('api');
|
||||
await app.init();
|
||||
}, 30000);
|
||||
|
||||
afterAll(async () => {
|
||||
if (app) await app.close();
|
||||
});
|
||||
|
||||
it('GET /api/healthz returns db ready', async () => {
|
||||
const res = await request(app.getHttpServer()).get('/api/healthz');
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body.ok).toBe(true);
|
||||
expect(res.body.database).toBe('ready');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user