| 12345678910111213141516171819202122232425 |
- import { describe, expect, it, vi } from 'vitest'
- import type { SessionEvent } from '@deepseek-ai/dsh-session'
- vi.mock('node:zlib', async (importOriginal) => {
- const actual = await importOriginal<typeof import('node:zlib')>()
- return {
- ...actual,
- zstdCompressSync: (input: ArrayBufferView) => Buffer.alloc(input.byteLength + 1),
- }
- })
- import { bindRecord, ZSTD_DATA_THRESHOLD_BYTES } from '../src/compression.ts'
- describe('SQLite compression fallback', () => {
- it('keeps large data as text when its Zstandard frame is not smaller', () => {
- const event = {
- type: 'assistant/message',
- seq: 0,
- time: 1,
- data: { text: 'x'.repeat(ZSTD_DATA_THRESHOLD_BYTES) },
- } as unknown as SessionEvent
- expect(typeof bindRecord(event).data).toBe('string')
- })
- })
|