0d3cb498a3
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Waiting to run
Test and Publish Multi-arch Docker Image / test (push) Waiting to run
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Blocked by required conditions
Validate Renovate Config / Validate Renovate Configuration (push) Waiting to run
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
63 lines
2.0 KiB
TypeScript
63 lines
2.0 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { loadYaml } from '../../src/util/yamlLoad';
|
|
|
|
describe('loadYaml', () => {
|
|
it('parses plain YAML documents', () => {
|
|
expect(loadYaml('a: 1\nb: hello')).toEqual({ a: 1, b: 'hello' });
|
|
});
|
|
|
|
it('applies YAML merge keys like js-yaml v4', () => {
|
|
const content = [
|
|
'defaults: &defaults',
|
|
' temperature: 0.5',
|
|
' max_tokens: 100',
|
|
'provider:',
|
|
' <<: *defaults',
|
|
' max_tokens: 200',
|
|
].join('\n');
|
|
|
|
expect(loadYaml(content)).toEqual({
|
|
defaults: { temperature: 0.5, max_tokens: 100 },
|
|
provider: { temperature: 0.5, max_tokens: 200 },
|
|
});
|
|
});
|
|
|
|
it('preserves js-yaml v4 legacy standard tags', () => {
|
|
expect(loadYaml('!!binary SGVsbG8=')).toEqual(new Uint8Array([72, 101, 108, 108, 111]));
|
|
expect(loadYaml('2024-01-02')).toEqual(new Date('2024-01-02T00:00:00.000Z'));
|
|
expect(loadYaml('!!omap [{a: 1}, {b: 2}]')).toEqual([{ a: 1 }, { b: 2 }]);
|
|
expect(loadYaml('!!pairs [{a: 1}, {b: 2}]')).toEqual([
|
|
['a', 1],
|
|
['b', 2],
|
|
]);
|
|
expect(loadYaml('!!set {a: null, b: null}')).toEqual({ a: null, b: null });
|
|
expect(() => loadYaml('!!set {a: not-null}')).toThrow(/cannot resolve a set item/);
|
|
});
|
|
|
|
it('returns undefined for empty input like js-yaml v4', () => {
|
|
expect(loadYaml('')).toBeUndefined();
|
|
});
|
|
|
|
it('returns undefined for whitespace-only input', () => {
|
|
expect(loadYaml(' \n\t\n')).toBeUndefined();
|
|
});
|
|
|
|
it('returns undefined for comment-only input', () => {
|
|
expect(loadYaml('# just a comment\n# another comment\n')).toBeUndefined();
|
|
});
|
|
|
|
it('still throws on invalid YAML', () => {
|
|
expect(() => loadYaml('a: [unclosed')).toThrow();
|
|
});
|
|
|
|
it('still throws on multi-document streams like js-yaml v4 load', () => {
|
|
expect(() => loadYaml('a: 1\n---\nb: 2')).toThrow(/single document/);
|
|
});
|
|
|
|
it('passes through additional load options', () => {
|
|
expect(() => loadYaml('a: [unclosed', { filename: 'my-config.yaml' })).toThrow(
|
|
/my-config\.yaml/,
|
|
);
|
|
});
|
|
});
|