fix test
Some checks failed
CD Preprod / Security gate (push) Successful in 29s
CD Preprod / Backend — Lint (push) Successful in 1m5s
CD Preprod / Frontend — Lint & Type-check (push) Successful in 1m14s
CD Preprod / Backend — Unit Tests (push) Successful in 1m8s
CD Preprod / Frontend — Unit Tests (push) Successful in 43s
CD Preprod / Backend — Integration Tests (push) Successful in 46s
CD Preprod / Build Backend (push) Successful in 16m40s
CD Preprod / Build Log Exporter (push) Successful in 1m8s
CD Preprod / Build Frontend (push) Successful in 39m48s
CD Preprod / Image security (${{ matrix.service }}, ${{ matrix.arch }}) (amd64, frontend) (push) Failing after 24s
CD Preprod / Image security (${{ matrix.service }}, ${{ matrix.arch }}) (amd64, backend) (push) Failing after 24s
CD Preprod / Image security (${{ matrix.service }}, ${{ matrix.arch }}) (amd64, log-exporter) (push) Failing after 22s
CD Preprod / Image security (${{ matrix.service }}, ${{ matrix.arch }}) (arm64, backend) (push) Failing after 24s
CD Preprod / Image security (${{ matrix.service }}, ${{ matrix.arch }}) (arm64, frontend) (push) Failing after 24s
CD Preprod / Image security (${{ matrix.service }}, ${{ matrix.arch }}) (arm64, log-exporter) (push) Failing after 21s
CD Preprod / Deploy to Preprod (push) Has been skipped
CD Preprod / Notify Success (push) Has been skipped
CD Preprod / Notify Failure (push) Has been skipped
Some checks failed
CD Preprod / Security gate (push) Successful in 29s
CD Preprod / Backend — Lint (push) Successful in 1m5s
CD Preprod / Frontend — Lint & Type-check (push) Successful in 1m14s
CD Preprod / Backend — Unit Tests (push) Successful in 1m8s
CD Preprod / Frontend — Unit Tests (push) Successful in 43s
CD Preprod / Backend — Integration Tests (push) Successful in 46s
CD Preprod / Build Backend (push) Successful in 16m40s
CD Preprod / Build Log Exporter (push) Successful in 1m8s
CD Preprod / Build Frontend (push) Successful in 39m48s
CD Preprod / Image security (${{ matrix.service }}, ${{ matrix.arch }}) (amd64, frontend) (push) Failing after 24s
CD Preprod / Image security (${{ matrix.service }}, ${{ matrix.arch }}) (amd64, backend) (push) Failing after 24s
CD Preprod / Image security (${{ matrix.service }}, ${{ matrix.arch }}) (amd64, log-exporter) (push) Failing after 22s
CD Preprod / Image security (${{ matrix.service }}, ${{ matrix.arch }}) (arm64, backend) (push) Failing after 24s
CD Preprod / Image security (${{ matrix.service }}, ${{ matrix.arch }}) (arm64, frontend) (push) Failing after 24s
CD Preprod / Image security (${{ matrix.service }}, ${{ matrix.arch }}) (arm64, log-exporter) (push) Failing after 21s
CD Preprod / Deploy to Preprod (push) Has been skipped
CD Preprod / Notify Success (push) Has been skipped
CD Preprod / Notify Failure (push) Has been skipped
This commit is contained in:
parent
99e01f97fc
commit
3434fa494d
@ -1,6 +1,6 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { INestApplication } from '@nestjs/common';
|
import { INestApplication } from '@nestjs/common';
|
||||||
import * as request from 'supertest';
|
import request from 'supertest';
|
||||||
import { AppModule } from '../src/app.module';
|
import { AppModule } from '../src/app.module';
|
||||||
|
|
||||||
describe('AppController (e2e)', () => {
|
describe('AppController (e2e)', () => {
|
||||||
|
|||||||
45
apps/backend/test/integration/redis-cache.spec.ts
Normal file
45
apps/backend/test/integration/redis-cache.spec.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { randomUUID } from 'crypto';
|
||||||
|
import { ConfigService } from '@nestjs/config';
|
||||||
|
import { RedisCacheAdapter } from '../../src/infrastructure/cache/redis-cache.adapter';
|
||||||
|
|
||||||
|
describe('Redis cache integration', () => {
|
||||||
|
let cache: RedisCacheAdapter;
|
||||||
|
const prefix = `integration:${randomUUID()}:`;
|
||||||
|
const keys = ['value', 'expires'].map(key => `${prefix}${key}`);
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
cache = new RedisCacheAdapter(
|
||||||
|
new ConfigService({
|
||||||
|
REDIS_HOST: process.env.REDIS_HOST,
|
||||||
|
REDIS_PORT: Number(process.env.REDIS_PORT),
|
||||||
|
REDIS_PASSWORD: process.env.REDIS_PASSWORD || undefined,
|
||||||
|
REDIS_DB: Number(process.env.REDIS_DB),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
await cache.onModuleInit();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
try {
|
||||||
|
// Delete only this suite's keys; never flush a shared database.
|
||||||
|
await cache.deleteMany(keys);
|
||||||
|
} finally {
|
||||||
|
await cache.onModuleDestroy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('round-trips cached application data and invalidates it', async () => {
|
||||||
|
const value = { amount: 125.5, currency: 'EUR', ports: ['FRLEH', 'USNYC'] };
|
||||||
|
await cache.set(keys[0], value, 60);
|
||||||
|
expect(await cache.get(keys[0])).toEqual(value);
|
||||||
|
await cache.delete(keys[0]);
|
||||||
|
expect(await cache.get(keys[0])).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('expires cached data using the server TTL', async () => {
|
||||||
|
await cache.set(keys[1], { valid: true }, 1);
|
||||||
|
expect(await cache.exists(keys[1])).toBe(true);
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1200));
|
||||||
|
expect(await cache.exists(keys[1])).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -1,7 +1,10 @@
|
|||||||
{
|
{
|
||||||
"moduleFileExtensions": ["js", "json", "ts"],
|
"moduleFileExtensions": ["js", "json", "ts"],
|
||||||
"rootDir": "../",
|
"rootDir": "../",
|
||||||
"testMatch": ["**/test/integration/**/*.spec.ts"],
|
"testMatch": [
|
||||||
|
"<rootDir>/test/integration/**/*.spec.ts",
|
||||||
|
"<rootDir>/src/infrastructure/persistence/typeorm/repositories/typeorm-trade-quota.repository.spec.ts"
|
||||||
|
],
|
||||||
"transform": {
|
"transform": {
|
||||||
"^.+\\.(t|j)s$": [
|
"^.+\\.(t|j)s$": [
|
||||||
"ts-jest",
|
"ts-jest",
|
||||||
@ -19,7 +22,7 @@
|
|||||||
"testEnvironment": "node",
|
"testEnvironment": "node",
|
||||||
"moduleNameMapper": {
|
"moduleNameMapper": {
|
||||||
"^@domain/(.*)$": "<rootDir>/src/domain/$1",
|
"^@domain/(.*)$": "<rootDir>/src/domain/$1",
|
||||||
"@application/(.*)$": "<rootDir>/src/application/$1",
|
"^@application/(.*)$": "<rootDir>/src/application/$1",
|
||||||
"^@infrastructure/(.*)$": "<rootDir>/src/infrastructure/$1"
|
"^@infrastructure/(.*)$": "<rootDir>/src/infrastructure/$1"
|
||||||
},
|
},
|
||||||
"transformIgnorePatterns": ["node_modules/(?!(@faker-js)/)"],
|
"transformIgnorePatterns": ["node_modules/(?!(@faker-js)/)"],
|
||||||
|
|||||||
@ -11,6 +11,18 @@ process.env.TEST_DB_USER = process.env.TEST_DB_USER || 'postgres';
|
|||||||
process.env.TEST_DB_PASSWORD = process.env.TEST_DB_PASSWORD || 'postgres';
|
process.env.TEST_DB_PASSWORD = process.env.TEST_DB_PASSWORD || 'postgres';
|
||||||
process.env.TEST_DB_NAME = process.env.TEST_DB_NAME || 'xpeditis_test';
|
process.env.TEST_DB_NAME = process.env.TEST_DB_NAME || 'xpeditis_test';
|
||||||
|
|
||||||
|
// Enable the repository integration suite using the disposable CI service.
|
||||||
|
// Never fall back to DATABASE_* (the application's deployment connection).
|
||||||
|
if (!process.env.TRADE_TEST_DATABASE_URL) {
|
||||||
|
const database = new URL('postgresql://localhost');
|
||||||
|
database.hostname = process.env.TEST_DB_HOST;
|
||||||
|
database.port = process.env.TEST_DB_PORT;
|
||||||
|
database.username = process.env.TEST_DB_USER;
|
||||||
|
database.password = process.env.TEST_DB_PASSWORD;
|
||||||
|
database.pathname = `/${process.env.TEST_DB_NAME}`;
|
||||||
|
process.env.TRADE_TEST_DATABASE_URL = database.toString();
|
||||||
|
}
|
||||||
|
|
||||||
// Redis test configuration
|
// Redis test configuration
|
||||||
process.env.REDIS_HOST = process.env.REDIS_HOST || 'localhost';
|
process.env.REDIS_HOST = process.env.REDIS_HOST || 'localhost';
|
||||||
process.env.REDIS_PORT = process.env.REDIS_PORT || '6379';
|
process.env.REDIS_PORT = process.env.REDIS_PORT || '6379';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user