import { validateEnvironment } from './environment';

describe('validateEnvironment', () => {
  it('accepts a valid environment', () => {
    const result = validateEnvironment({
      NODE_ENV: 'test',
      PORT: '3000',
      DATABASE_URL: 'postgresql://velody:velody@localhost:5432/velody?schema=public',
      STORAGE_ROOT: '/tmp/velody',
      PUBLIC_BASE_URL: 'http://localhost:3000',
      DEVICE_BOOTSTRAP_SECRET: 'secret',
      MAX_UPLOAD_SIZE_BYTES: '1024',
    });

    expect(result.PORT).toBe(3000);
    expect(result.MAX_UPLOAD_SIZE_BYTES).toBe(1024);
  });

  it('throws for missing values', () => {
    expect(() =>
      validateEnvironment({
        NODE_ENV: 'test',
      }),
    ).toThrow(/Invalid environment configuration/);
  });
});
