n8n/.github/scripts/attest-image-sbom.test.mjs
Declan Carroll a773c7b46a
ci: Enrich and gate release and image SBOMs on resolved SPDX licenses (no-changelog) (#31769)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 08:24:50 +00:00

38 lines
1.0 KiB
JavaScript

import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { parseTargets } from './attest-image-sbom.mjs';
describe('parseTargets', () => {
it('builds a target per image when both ref and digest are present', () => {
const targets = parseTargets({
N8N_IMAGE: 'ghcr.io/n8n-io/n8n',
N8N_DIGEST: 'sha256:aaa',
RUNNERS_IMAGE: 'ghcr.io/n8n-io/runners',
RUNNERS_DIGEST: 'sha256:bbb',
DISTROLESS_IMAGE: 'ghcr.io/n8n-io/runners',
DISTROLESS_DIGEST: 'sha256:ccc',
});
assert.deepEqual(
targets.map((t) => t.label),
['n8n', 'runners', 'runners-distroless'],
);
});
it('skips an image with no digest (not built for this release type)', () => {
const targets = parseTargets({
N8N_IMAGE: 'ghcr.io/n8n-io/n8n',
N8N_DIGEST: 'sha256:aaa',
RUNNERS_IMAGE: 'ghcr.io/n8n-io/runners',
RUNNERS_DIGEST: '',
});
assert.deepEqual(
targets.map((t) => t.label),
['n8n'],
);
});
it('returns nothing when no digests are present', () => {
assert.deepEqual(parseTargets({}), []);
});
});