import { describe, expect, it } from 'bun:test';
import { needsDocker, preflight } from './preflight';
import { CATALOGUE, byId } from './catalogue';

describe('needsDocker is derived, not declared', () => {
  it('is true for exactly the entries that can provision', () => {
    for (const e of CATALOGUE) expect(needsDocker(e)).toBe(e.modes.includes('provisioned'));
  });
});

describe('preflight is per mode, not per entry', () => {
  it('allows pointing at an existing instance without Docker', async () => {
    // The whole point: a host with no Docker can still use Photos against an Immich elsewhere.
    // Refusing the entry outright is the over-strict check that makes people bypass the installer.
    const photos = byId('photos')!;
    expect(await preflight(photos, 'existing')).toEqual({ ok: true });
  });

  it('allows a config-only sidecar regardless', async () => {
    expect(await preflight(byId('email')!, 'config')).toEqual({ ok: true });
  });
});
