import test from 'node:test'; import assert from 'node:assert/strict'; import { isGooseSessionPgConfigured, resolveGooseSessionPgUrl, } from './goose-session-cost.mjs'; test('resolveGooseSessionPgUrl prefers GOOSE_SESSION_DB_URL', () => { assert.equal( resolveGooseSessionPgUrl({ GOOSE_SESSION_DB_URL: 'postgresql://u:p@host:5432/db' }), 'postgresql://u:p@host:5432/db', ); }); test('resolveGooseSessionPgUrl builds local default DSN', () => { assert.equal( resolveGooseSessionPgUrl({ GOOSE_SESSION_PG_HOST: '127.0.0.1', GOOSE_SESSION_PG_PORT: '5432', GOOSE_SESSION_PG_DATABASE: 'memind_sessions', GOOSE_SESSION_PG_USER: 'john', }), 'postgresql://john@127.0.0.1:5432/memind_sessions', ); }); test('isGooseSessionPgConfigured can be disabled explicitly', () => { assert.equal(isGooseSessionPgConfigured({ GOOSE_SESSION_PG_DISABLE: '1' }), false); assert.equal(isGooseSessionPgConfigured({ GOOSE_SESSION_DB_URL: 'postgresql://x' }), true); });