import assert from 'node:assert/strict' import { test } from 'node:test' import { REMOVED_AUTH_OPTIONS, rejectRemovedAuthOptions } from '../src/auth-options.ts' test('no removed options passes', () => { assert.doesNotThrow(() => rejectRemovedAuthOptions({ owner: 'o', repo: 'r', prNumber: 1 })) assert.doesNotThrow(() => rejectRemovedAuthOptions({ secretName: undefined, integrationName: null })) assert.doesNotThrow(() => rejectRemovedAuthOptions(undefined)) }) for (const key of REMOVED_AUTH_OPTIONS) { test(`${key} throws and points to the credentials map`, () => { assert.throws( () => rejectRemovedAuthOptions({ [key]: 'githubKodyBotToken' }), (error: Error) => { assert.match(error.message, new RegExp(`removed the "${key}" option`)) assert.match(error.message, /credential slot named "github"/) assert.match(error.message, /--credential github=githubKodyBotToken/) assert.match(error.message, /\{ credentials: \{ github: "githubKodyBotToken" \} \}/) return true }, ) }) } test('several removed options are all named', () => { assert.throws( () => rejectRemovedAuthOptions({ secretName: 'a', account: 'b' }), /removed the "secretName", "account" options/, ) })