feat(mindspace): enforce PostgreSQL user data delivery
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
applyMemindRuntimeProfile,
|
||||
resolveMemindRuntimeProfile,
|
||||
} from './memind-runtime-profile.mjs';
|
||||
|
||||
test('resolveMemindRuntimeProfile defaults to local for dev', () => {
|
||||
assert.equal(resolveMemindRuntimeProfile({}), 'local');
|
||||
assert.equal(resolveMemindRuntimeProfile({ NODE_ENV: 'development' }), 'local');
|
||||
});
|
||||
|
||||
test('resolveMemindRuntimeProfile honors explicit profile and production NODE_ENV', () => {
|
||||
assert.equal(resolveMemindRuntimeProfile({ MEMIND_RUNTIME_PROFILE: 'split-service' }), 'split-service');
|
||||
assert.equal(resolveMemindRuntimeProfile({ NODE_ENV: 'production' }), 'production');
|
||||
});
|
||||
|
||||
test('applyMemindRuntimeProfile local forces monolith adapter and repo storage', () => {
|
||||
const env = {
|
||||
MINDSPACE_SERVER_ADAPTER: 'remote',
|
||||
MINDSPACE_REMOTE_BASE_URL: 'http://127.0.0.1:8082',
|
||||
};
|
||||
const result = applyMemindRuntimeProfile({
|
||||
rootDir: '/tmp/memind',
|
||||
env,
|
||||
profile: 'local',
|
||||
});
|
||||
assert.equal(result.profile, 'local');
|
||||
assert.equal(env.MINDSPACE_SERVER_ADAPTER, 'local');
|
||||
assert.match(env.MINDSPACE_STORAGE_ROOT, /\/tmp\/memind\/data\/mindspace$/);
|
||||
});
|
||||
|
||||
test('applyMemindRuntimeProfile split-service expands auth token reference', () => {
|
||||
const env = {
|
||||
TKMIND_SERVER__SECRET_KEY: 'local-dev-secret',
|
||||
MINDSPACE_REMOTE_AUTH_TOKEN: '${TKMIND_SERVER__SECRET_KEY}',
|
||||
};
|
||||
applyMemindRuntimeProfile({ env, profile: 'split-service' });
|
||||
assert.equal(env.MINDSPACE_SERVER_ADAPTER, 'remote');
|
||||
assert.equal(env.MINDSPACE_REMOTE_AUTH_TOKEN, 'local-dev-secret');
|
||||
});
|
||||
|
||||
test('applyMemindRuntimeProfile production does not override adapter', () => {
|
||||
const env = {
|
||||
MINDSPACE_SERVER_ADAPTER: 'remote',
|
||||
MINDSPACE_REMOTE_BASE_URL: 'http://127.0.0.1:8082',
|
||||
MINDSPACE_REMOTE_AUTH_TOKEN: 'prod-token',
|
||||
};
|
||||
const result = applyMemindRuntimeProfile({ env, profile: 'production' });
|
||||
assert.equal(result.profile, 'production');
|
||||
assert.equal(env.MINDSPACE_SERVER_ADAPTER, 'remote');
|
||||
assert.equal(env.MINDSPACE_REMOTE_AUTH_TOKEN, 'prod-token');
|
||||
});
|
||||
Reference in New Issue
Block a user