import { describe, test, expect } from 'bun:test'; import { PLCBundle } from '../src/plcbundle'; describe('Error Handling', () => { test('handles missing index file gracefully', async () => { const bundle = new PLCBundle('/nonexistent/path'); try { await bundle.loadIndex(); expect(true).toBe(false); // Should throw } catch (error) { expect(error).toBeDefined(); } }); test('handles invalid bundle numbers', async () => { const bundle = new PLCBundle('./test-data'); // Test with negative number - padStart will create "0000-1" const path = bundle.getBundlePath(-1); expect(path).toContain('0000-1.jsonl.zst'); // Test with zero const path0 = bundle.getBundlePath(0); expect(path0).toContain('000000.jsonl.zst'); // Test with large number const pathLarge = bundle.getBundlePath(999999); expect(pathLarge).toContain('999999.jsonl.zst'); }); test('handles malformed operations', () => { const bundle = new PLCBundle(); try { bundle.parseOperations('invalid json\n{bad'); expect(true).toBe(false); // Should throw } catch (error) { expect(error).toBeDefined(); } }); });