import test from 'node:test'; import assert from 'node:assert/strict'; import validation from '../src/shared/validation.cjs'; const { normalizeBaseUrl, assertCommitMessage, assertDeploymentRequest, assertHttpUrl } = validation; test('normalizes Gitea base URL', () => { assert.equal(normalizeBaseUrl('https://gitea.example.com/'), 'https://gitea.example.com'); }); test('rejects blank commit messages', () => { assert.throws(() => assertCommitMessage(' '), /commit message/i); }); test('requires exact SHA and workflow profile', () => { assert.throws(() => assertDeploymentRequest({ branch: 'main', workflowFile: 'deploy.yml' }, 'nope'), /commit SHA/i); }); test('accepts Unraid DockerMan WebUI placeholders only when explicitly enabled', () => { assert.equal(assertHttpUrl('http://[IP]:[PORT:1223]/', { allowUnraidTemplate: true }), 'http://[IP]:[PORT:1223]/'); assert.throws(() => assertHttpUrl('http://[IP]:[PORT:1223]/')); });