remora/web/server/config.test.mjs

28 lines
917 B
JavaScript
Raw Normal View History

import assert from 'node:assert/strict'
import { test } from 'node:test'
import { loadConfig } from './config.mjs'
const environment = {
REMORA_WEB_PUBLIC_ORIGIN: 'https://remora.example.test',
REMORA_WEB_API_UPSTREAM: 'https://api.example.test/v1',
REMORA_WEB_OIDC_AUTHORITY: 'https://identity.example.test',
REMORA_WEB_OIDC_CLIENT_ID: 'remora-web',
REMORA_WEB_OIDC_CLIENT_SECRET: 'client-secret',
REMORA_WEB_SESSION_URL: 'redis://session.example.test',
}
test('derives the event endpoint from the API upstream', () => {
const config = loadConfig(environment)
assert.equal(config.eventsUpstream.href, 'wss://api.example.test/v1/events')
})
test('uses the explicit event endpoint', () => {
const config = loadConfig({
...environment,
REMORA_WEB_EVENTS_UPSTREAM: 'http://events.example.test/stream',
})
assert.equal(config.eventsUpstream.href, 'ws://events.example.test/stream')
})