Files
memind/release-gate/ci-status.test.mjs
T

42 lines
1.0 KiB
JavaScript
Raw Normal View History

import assert from 'node:assert/strict';
import test from 'node:test';
import { isReleaseCiAcceptable } from './ci-status.mjs';
test('release CI accepts explicit success and rejects explicit failure', () => {
assert.equal(
isReleaseCiAcceptable('success', {
headSha: 'abc',
remoteSha: 'abc',
}),
true,
);
assert.equal(
isReleaseCiAcceptable('failure', {
headSha: 'abc',
remoteSha: 'abc',
}),
false,
);
});
test('release CI accepts missing or pending status when candidate equals origin/main', () => {
const sha = 'c7718c683b216f08865e04edc67f4217f6abc3c1';
assert.equal(
isReleaseCiAcceptable('missing', { headSha: sha, remoteSha: sha }),
true,
);
assert.equal(
isReleaseCiAcceptable('pending', { headSha: sha, remoteSha: sha }),
true,
);
assert.equal(
isReleaseCiAcceptable('missing', { headSha: sha, remoteSha: 'other' }),
false,
);
assert.equal(
isReleaseCiAcceptable('pending', { headSha: sha, remoteSha: 'other' }),
false,
);
});