test(session): run persistence consumers against both backends
This commit is contained in:
1 parent
b467fa6ee5
commit
73b971fa16
112 files changed
+2309
-1970
No files matched your search
@@ -0,0 +1,26 @@
|
||||
/** Read persisted histories through the installed profile's persistence service. */
|
||||
import { writeFile } from 'node:fs/promises'
|
||||
|
||||
/** Private profile reader label. */
|
||||
export const name = 'python-sdk-session-reader'
|
||||
/** Persistence must be mounted before this fixture reads histories. */
|
||||
export const inject = ['sessionPersistence']
|
||||
|
||||
/**
|
||||
* Write complete logical histories after the SDK profile mounts persistence.
|
||||
* @param {import('@deepseek-ai/cordis').Context} ctx - Installed SDK profile services.
|
||||
* @param {{ output: string }} config - Private JSON output file.
|
||||
*/
|
||||
export async function apply(ctx, config) {
|
||||
const sessions = {}
|
||||
for (const snapshot of await ctx.sessionPersistence.list()) {
|
||||
const handle = await ctx.sessionPersistence.open(snapshot.header.id, 'read')
|
||||
try {
|
||||
const { events } = await handle.read()
|
||||
sessions[handle.header.id] = [{ type: 'session', ...handle.header }, ...events]
|
||||
} finally {
|
||||
await handle.close()
|
||||
}
|
||||
}
|
||||
await writeFile(config.output, JSON.stringify(sessions), { mode: 0o600 })
|
||||
}
|
||||
Reference in new issue
Block a user