repositories / will

will

owned by bugabinga

src/agent/config.test.ts

Raw
File outline
import assert from 'node:assert/strict'
import { test } from 'node:test'
import { resolveSessionMode } from './config.ts'

test('explicit fake wins even with a key', () => {
  assert.equal(resolveSessionMode({ WILL_SESSION_MODE: 'fake', ZAI_API_KEY: 'k' }), 'fake')
})

test('no env at all falls back to fake', () => {
  assert.equal(resolveSessionMode({}), 'fake')
})

test('key alone gives the real session', () => {
  assert.equal(resolveSessionMode({ ZAI_API_KEY: 'k' }), 'real')
})

test('explicit real without a key fails loudly', () => {
  assert.throws(() => resolveSessionMode({ WILL_SESSION_MODE: 'real' }), /ZAI_API_KEY/)
})

test('explicit real with a key is real', () => {
  assert.equal(resolveSessionMode({ WILL_SESSION_MODE: 'real', ZAI_API_KEY: 'k' }), 'real')
})