8c1ae7550d
Goosed GET /sessions/:id returns accumulated_cost null while memind_sessions PG has the real upstream cost. Fall back to PG before token estimate billing. Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
1005 B
JavaScript
31 lines
1005 B
JavaScript
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);
|
|
});
|