import { loadEnvironment } from './environment';

describe('loadEnvironment', () => {
  it('requires database and redis URLs', () => {
    expect(() => loadEnvironment({})).toThrow('DATABASE_URL');
  });

  it('returns build metadata without secrets', () => {
    expect(
      loadEnvironment({
        DATABASE_URL: 'postgresql://u:p@postgres:5432/db',
        REDIS_URL: 'redis://redis:6379',
        OIDC_ISSUER: 'https://idp.example.test/',
        OIDC_AUDIENCE: 'travel-planner-api',
        APP_VERSION: '1.2.3',
        TEAMCITY_BUILD_NUMBER: '42',
        SOURCE_REVISION: 'abc123',
      }),
    ).toEqual({
      databaseUrl: 'postgresql://u:p@postgres:5432/db',
      redisUrl: 'redis://redis:6379',
      oidcIssuer: 'https://idp.example.test/',
      oidcAudience: 'travel-planner-api',
      appVersion: '1.2.3',
      teamCityBuildNumber: '42',
      sourceRevision: 'abc123',
    });
  });
});
