import { describe, it, expect } from 'vitest';
import { spaceDataDir, spaceWorkspaceDir, spaceFilesDir, spaceLogsDir } from './paths.js';

describe('space paths', () => {
  it('builds the data (folder) dir under dataRoot/spaces/{id}', () => {
    expect(spaceDataDir('/data', 'abc')).toBe('/data/spaces/abc');
  });
  it('builds the workspace dir under worktreeDir/space/{id}', () => {
    expect(spaceWorkspaceDir('/wt', 'abc')).toBe('/wt/space/abc');
    expect(spaceFilesDir('/wt', 'abc')).toBe('/wt/space/abc/files');
    expect(spaceLogsDir('/wt', 'abc')).toBe('/wt/space/abc/logs');
  });
  it('rejects ids that would escape the root', () => {
    expect(() => spaceDataDir('/data', '../etc')).toThrow();
    expect(() => spaceWorkspaceDir('/wt', 'a/b')).toThrow();
  });
});
