mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
test(server): src/config takes fixed test values from the setup file, so suites stop mocking it
tests/setup.ts mocks src/config once with tests/helpers/test-config.ts. A suite that needs other values calls overrideTestConfig(), and the setup file restores the defaults after every case. The 191 per-file factories are gone; config.test.ts takes the real module through vi.unmock, and the few suites that signed tokens with their own literal secret read it from TEST_CONFIG.
This commit is contained in:
@@ -7,8 +7,6 @@ vi.mock('../../../../src/db/database', async () => {
|
||||
return { db, closeDb: () => {}, reinitialize: () => {} };
|
||||
});
|
||||
|
||||
vi.mock('../../../../src/config', () => ({ ENCRYPTION_KEY: 'storage-admin-test-key' }));
|
||||
|
||||
import { db as testDb } from '../../../../src/db/database';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
|
||||
@@ -7,8 +7,6 @@ vi.mock('../../../../src/db/database', async () => {
|
||||
return { db, closeDb: () => {}, reinitialize: () => {} };
|
||||
});
|
||||
|
||||
vi.mock('../../../../src/config', () => ({ ENCRYPTION_KEY: 'storage-jobs-test-key' }));
|
||||
|
||||
import { db as testDb } from '../../../../src/db/database';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
|
||||
@@ -11,9 +11,6 @@ vi.mock('../../../../src/db/database', async () => {
|
||||
return { db, closeDb: () => {}, reinitialize: () => {} };
|
||||
});
|
||||
|
||||
|
||||
vi.mock('../../../../src/config', () => ({ ENCRYPTION_KEY: 'storage-registry-test-key' }));
|
||||
|
||||
import { db as testDb } from '../../../../src/db/database';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
|
||||
vi.mock('../../../../src/config', () => ({ ENCRYPTION_KEY: 'storage-secrets-test-key' }));
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
import { MASKED_SETTING_VALUE, type StorageConfig } from '@trek/shared';
|
||||
import {
|
||||
@@ -38,7 +36,6 @@ const LOCAL_ONLY: StorageConfig = {
|
||||
categories: {},
|
||||
};
|
||||
|
||||
|
||||
describe('encryptStorageSecrets', () => {
|
||||
it('encrypts plaintext secrets and round-trips through decrypt', () => {
|
||||
const out = encryptStorageSecrets(s3Config('sk-plain'));
|
||||
|
||||
@@ -7,8 +7,6 @@ vi.mock('../../../../src/db/database', async () => {
|
||||
return { db, closeDb: () => {}, reinitialize: () => {} };
|
||||
});
|
||||
|
||||
vi.mock('../../../../src/config', () => ({ ENCRYPTION_KEY: 'storage-stats-test-key' }));
|
||||
|
||||
import { db as testDb } from '../../../../src/db/database';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
|
||||
Reference in New Issue
Block a user