fix(billing): read Goose accumulated_cost from PostgreSQL fallback
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>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user