Hub 2.0 step 3: releases per product, with requirements
- Release.product and requires; unique (product, version); latest version per product (latest_version stays Cross Events' latest) - Release sources per product (Releases page): repository, tag prefix, notes file. Defaults: every product from crosscode-platform plus Cross Events' v1.2.3 tags from hope-events. A product's releases are only removed when all its sources were read and found tags - "— requires accounts 1.2.0" in a notes heading: Request update answers 409 REQUIREMENT_NOT_MET until the church's install of that product is new enough; install page and Releases page show it; v2 replies carry requires - @crosscode/contracts 1.1.0 vendored (optional requires on releases) - Alerts, dashboard and install lists compare against each product's latest Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,7 +33,7 @@ const mockDb = {
|
||||
};
|
||||
jest.mock('../src/config/db', () => mockDb);
|
||||
jest.mock('../src/utils/settings', () => ({ getSettings: jest.fn(async () => ({ latest_version: '2.1.1' })) }));
|
||||
jest.mock('../src/utils/releases', () => ({ releasesForInstall: jest.fn(async () => []) }));
|
||||
jest.mock('../src/utils/releases', () => ({ releasesForInstall: jest.fn(async () => []), latestVersions: jest.fn(async () => ({ events: '2.1.1' })) }));
|
||||
jest.mock('../src/utils/notices', () => ({ noticesForInstall: jest.fn(async () => []) }));
|
||||
jest.mock('../src/utils/licenceToken', () => ({ sign: jest.fn(() => 'hel1.token.sig'), buildPayload: jest.fn(() => ({})) }));
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ const mockL_EVENTS = '2d0b5e4c-7f6a-4b8c-9d9e-3f4a5b6c7d8e';
|
||||
const mockL_WEBSITE = '3e1c6f5d-8a7b-4c9d-8eaf-4a5b6c7d8e9f';
|
||||
const mockL_OTHER = '4f2d7a6e-9b8c-4dae-9fb0-5b6c7d8e9fa0';
|
||||
const mockDb = (() => {
|
||||
const t = { licences: [], installs: [], events: [], heartbeats: [] };
|
||||
const t = { licences: [], installs: [], events: [], heartbeats: [], releases: [] };
|
||||
const id = p => `${p}_${crypto.randomUUID()}`;
|
||||
const customers = { [mockC1]: { id: mockC1, name: 'Hope Family Church' }, [mockC2]: { id: mockC2, name: 'Grace Church' } };
|
||||
const withLicence = l => l && { ...l, install: t.installs.find(i => i.licenceId === l.id) || null, customer: customers[l.customerId] };
|
||||
@@ -26,8 +26,9 @@ const mockDb = (() => {
|
||||
create: jest.fn(async ({ data }) => { const row = { id: crypto.randomUUID(), registeredAt: new Date(Date.now() + t.installs.length), releasedAt: null, ...data }; t.installs.push(row); return row; }),
|
||||
update: jest.fn(async ({ where, data }) => Object.assign(t.installs.find(i => i.id === where.id), Object.fromEntries(Object.entries(data).filter(([, v]) => v !== undefined)))),
|
||||
findMany: jest.fn(async ({ where, select }) => t.installs
|
||||
.filter(i => i.customerId === where.customerId && i.id !== where.id.not && i.releasedAt === null && i.publicKey != null)
|
||||
.filter(i => t.licences.find(l => l.id === i.licenceId)?.status !== 'revoked')
|
||||
.filter(i => i.customerId === where.customerId && i.id !== where.id.not && i.releasedAt === null)
|
||||
.filter(i => !where.publicKey || i.publicKey != null)
|
||||
.filter(i => !where.licence || t.licences.find(l => l.id === i.licenceId)?.status !== 'revoked')
|
||||
.sort((a, b) => a.registeredAt - b.registeredAt)
|
||||
.map(i => Object.fromEntries(Object.keys(select).map(k => [k, i[k]])))),
|
||||
},
|
||||
@@ -38,6 +39,7 @@ const mockDb = (() => {
|
||||
findMany: jest.fn(async () => []),
|
||||
},
|
||||
heartbeat: { create: jest.fn(async ({ data }) => { t.heartbeats.push(data); return data; }) },
|
||||
release: { findMany: jest.fn(async ({ where } = {}) => t.releases.filter(r => !where?.product || r.product === where.product)) },
|
||||
customer: { findUnique: jest.fn(async ({ where }) => customers[where.id]) },
|
||||
$transaction: jest.fn(async ops => Promise.all(ops)),
|
||||
};
|
||||
@@ -45,10 +47,7 @@ const mockDb = (() => {
|
||||
jest.mock('../src/config/db', () => mockDb);
|
||||
// Every test registers: the hourly register limit would cut in part-way through the file.
|
||||
jest.mock('express-rate-limit', () => () => (req, res, next) => next());
|
||||
jest.mock('../src/utils/settings', () => ({ getSettings: jest.fn(async () => ({ latest_version: '2.4.0' })) }));
|
||||
jest.mock('../src/utils/releases', () => ({
|
||||
releasesForInstall: jest.fn(async () => [{ version: '2.4.0', releasedAt: '2026-11-20T08:00:00.000Z', urgent: false, notes: '- Event feed' }]),
|
||||
}));
|
||||
jest.mock('../src/utils/settings', () => ({ getSettings: jest.fn(async () => ({})), setSettings: jest.fn(async () => ({})) }));
|
||||
jest.mock('../src/utils/notices', () => ({ noticesForInstall: jest.fn(async () => []) }));
|
||||
|
||||
process.env.HUB_ENCRYPTION_KEY = 'test-encryption-key-that-is-long-enough-123';
|
||||
@@ -80,6 +79,12 @@ afterAll(() => new Promise(resolve => server.close(resolve)));
|
||||
beforeEach(() => {
|
||||
const { t } = mockDb;
|
||||
t.installs.length = 0; t.events.length = 0; t.heartbeats.length = 0;
|
||||
t.releases.splice(0, t.releases.length,
|
||||
{ product: 'events', version: '2.4.0', releasedAt: new Date('2026-11-20T08:00:00Z'), urgent: false, notes: '- Event feed', requires: [] },
|
||||
{ product: 'events', version: '3.0.0', releasedAt: new Date('2026-12-01T08:00:00Z'), urgent: false, notes: '- Sign in with your church account', requires: [{ product: 'accounts', version: '1.2.0' }] },
|
||||
{ product: 'website', version: '1.0.0', releasedAt: new Date('2026-11-25T08:00:00Z'), urgent: false, notes: '- First release', requires: [] },
|
||||
{ product: 'website', version: '1.1.0', releasedAt: new Date('2026-12-05T08:00:00Z'), urgent: false, notes: '- Sermon series', requires: [] },
|
||||
);
|
||||
t.licences.splice(0, t.licences.length,
|
||||
{ id: mockL_EVENTS, customerId: mockC1, product: 'events', key: KEYS.events, status: 'active', plan: 'Grow', expiresAt: null, graceDays: 14, aiMonthlyCapCents: 0 },
|
||||
{ id: mockL_WEBSITE, customerId: mockC1, product: 'website', key: KEYS.website, status: 'active', plan: 'Website', expiresAt: null, graceDays: 14, aiMonthlyCapCents: 0 },
|
||||
@@ -191,11 +196,22 @@ describe('heartbeat', () => {
|
||||
expect(json.linkedProducts.map(l => [l.product, l.installId])).toEqual([['website', website.installId]]);
|
||||
});
|
||||
|
||||
test('releases are Cross Events\' only until releases per product', async () => {
|
||||
test('each product is told its own releases', async () => {
|
||||
const { json: website } = await register(websiteRegistration());
|
||||
expect(website).toMatchObject({ latestVersion: null, releases: [] });
|
||||
expect(website.latestVersion).toBe('1.1.0');
|
||||
expect(website.releases.map(r => r.version)).toEqual(['1.1.0']);
|
||||
const { json: events } = await register(eventsRegistration());
|
||||
expect(events.latestVersion).toBe('2.4.0');
|
||||
expect(events.latestVersion).toBe('3.0.0');
|
||||
expect(events.releases.map(r => r.version)).toEqual(['3.0.0', '2.4.0']);
|
||||
});
|
||||
|
||||
test('v2 replies carry requirements; v1 replies are as before', async () => {
|
||||
const { json: v2 } = await register(eventsRegistration());
|
||||
expect(v2.releases[0].requires).toEqual([{ product: 'accounts', version: '1.2.0' }]);
|
||||
expect(v2.releases[1]).not.toHaveProperty('requires');
|
||||
const r = eventsRegistration();
|
||||
const { json: v1 } = await register({ protocolVersion: 1, licenceKey: r.licenceKey, install: { name: r.install.name, url: r.install.url, version: '2.1.1' } });
|
||||
expect(v1.releases.every(x => !('requires' in x))).toBe(true);
|
||||
});
|
||||
|
||||
test('a heartbeat for another product is refused', async () => {
|
||||
@@ -238,11 +254,38 @@ describe('update requests (v2)', () => {
|
||||
expect((await res.json()).code).toBe('INVALID_REQUEST');
|
||||
});
|
||||
|
||||
test('a v2 request is recorded', async () => {
|
||||
test('an update that needs Accounts first is refused until Accounts is new enough', async () => {
|
||||
const { json: reg } = await register(eventsRegistration());
|
||||
const res = await signed('/installs/update-request', reg, { protocolVersion: 2, version: '2.3.0' });
|
||||
const json = await res.json();
|
||||
let res = await signed('/installs/update-request', reg, { protocolVersion: 2, version: '2.3.0' });
|
||||
let json = await res.json();
|
||||
expect(res.status).toBe(409);
|
||||
expect(json).toMatchObject({ code: 'REQUIREMENT_NOT_MET', requirements: [{ product: 'accounts', version: '1.2.0', current: null }] });
|
||||
expect(json.message).toContain('Accounts 1.2.0 or later must be installed first');
|
||||
|
||||
// The church's Accounts install, on 1.1.0: still refused, and the message says what it runs.
|
||||
mockDb.t.installs.push({ id: crypto.randomUUID(), customerId: mockC1, product: 'accounts', version: '1.1.0', releasedAt: null, registeredAt: new Date() });
|
||||
json = await (await signed('/installs/update-request', reg, { protocolVersion: 2, version: '2.3.0' })).json();
|
||||
expect(json.message).toContain('Accounts must be updated to 1.2.0 first (it runs 1.1.0)');
|
||||
|
||||
// On 1.2.0: the request goes through, and fits the contract.
|
||||
mockDb.t.installs.find(i => i.product === 'accounts').version = '1.2.0';
|
||||
res = await signed('/installs/update-request', reg, { protocolVersion: 2, version: '2.3.0' });
|
||||
json = await res.json();
|
||||
expect(res.status).toBe(201);
|
||||
expect(json.version).toBe('3.0.0');
|
||||
expect(hub.updateRequestResponseSchema.safeParse(json).error?.issues ?? []).toEqual([]);
|
||||
});
|
||||
|
||||
test('another church\'s Accounts doesn\'t count', async () => {
|
||||
mockDb.t.installs.push({ id: crypto.randomUUID(), customerId: mockC2, product: 'accounts', version: '9.0.0', releasedAt: null, registeredAt: new Date() });
|
||||
const { json: reg } = await register(eventsRegistration());
|
||||
const res = await signed('/installs/update-request', reg, { protocolVersion: 2, version: '2.3.0' });
|
||||
expect(res.status).toBe(409);
|
||||
});
|
||||
|
||||
test('a product with no requirements updates as before', async () => {
|
||||
const { json: reg } = await register(websiteRegistration());
|
||||
const res = await signed('/installs/update-request', reg, { protocolVersion: 2, version: '1.0.0' });
|
||||
expect(res.status).toBe(201);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
// Hub 2.0 step 3: releases per product from several git sources, requirements in the notes, and
|
||||
// the rules that keep an unreachable source from wiping releases. Gitea is faked with a fetch
|
||||
// stub; the database is in memory.
|
||||
|
||||
const mockReleases = [];
|
||||
const mockSettings = { values: {} };
|
||||
const mockDb = {
|
||||
release: {
|
||||
findMany: jest.fn(async ({ where, select } = {}) => {
|
||||
const rows = mockReleases.filter(r => !where?.product || r.product === where.product);
|
||||
return select ? rows.map(r => Object.fromEntries(Object.keys(select).map(k => [k, r[k]]))) : rows;
|
||||
}),
|
||||
create: jest.fn(async ({ data }) => { const row = { id: `r${mockReleases.length + 1}_${data.product}_${data.version}`, requires: [], ...data }; mockReleases.push(row); return row; }),
|
||||
update: jest.fn(async ({ where, data }) => Object.assign(mockReleases.find(r => r.id === where.id), data)),
|
||||
deleteMany: jest.fn(async ({ where }) => {
|
||||
const ids = new Set(where.id.in);
|
||||
for (let i = mockReleases.length - 1; i >= 0; i--) if (ids.has(mockReleases[i].id)) mockReleases.splice(i, 1);
|
||||
return { count: ids.size };
|
||||
}),
|
||||
},
|
||||
};
|
||||
jest.mock('../src/config/db', () => mockDb);
|
||||
jest.mock('../src/utils/settings', () => ({
|
||||
getSettings: jest.fn(async () => ({ ...mockSettings.values })),
|
||||
setSettings: jest.fn(async v => { Object.assign(mockSettings.values, v); return mockSettings.values; }),
|
||||
releaseRepoToken: jest.fn(async () => ''),
|
||||
}));
|
||||
|
||||
const { parseNotes, parseRequirements, tagPattern, defaultSources, cleanSources, releaseSources, syncReleases, PLATFORM_REPO } = require('../src/utils/releaseSync');
|
||||
const { unmetRequirements, latestByProduct } = require('../src/utils/releases');
|
||||
|
||||
const LEGACY = 'https://c-git.crosscode.co.za/joshua/hope-events';
|
||||
const api = repo => `https://c-git.crosscode.co.za/api/v1/repos/joshua/${repo}`;
|
||||
|
||||
/** A fake Gitea: { 'hope-events': { tags: [...], files: { 'WHATS-NEW.md': '...' } } }; a repo set to 'down' fails. */
|
||||
let gitea;
|
||||
global.fetch = jest.fn(async url => {
|
||||
const m = /\/repos\/joshua\/([^/]+)\/(tags|raw\/(.+))/.exec(url);
|
||||
const repo = m && gitea[m[1]];
|
||||
if (repo === 'down') throw new Error('connect ECONNREFUSED');
|
||||
if (!repo) return { ok: false, status: 404 };
|
||||
if (m[2].startsWith('tags')) {
|
||||
const page = Number(new URL(url).searchParams.get('page'));
|
||||
return { ok: true, status: 200, json: async () => (page === 1 ? repo.tags.map(name => ({ name, commit: { created: '2026-11-01T10:00:00Z' } })) : []) };
|
||||
}
|
||||
const file = repo.files?.[decodeURIComponent(m[3])];
|
||||
return file == null ? { ok: false, status: 404 } : { ok: true, status: 200, text: async () => file };
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
mockReleases.length = 0;
|
||||
mockSettings.values = { release_repo_url: LEGACY, release_notes_path: 'WHATS-NEW.md' };
|
||||
gitea = {
|
||||
'hope-events': { tags: ['v2.0.0', 'v2.1.0', 'v2.1.1', 'not-a-version'], files: { 'WHATS-NEW.md': '## 2.1.1\n- Feedback in the background\n## 2.1.0\n- Feedback page' } },
|
||||
'crosscode-platform': {
|
||||
tags: ['contracts@1.0.0', 'contracts@1.1.0', 'events@2.2.0', 'events@3.0.0', 'accounts@1.2.0', 'website@1.0.0'],
|
||||
files: {
|
||||
'apps/events/WHATS-NEW.md': '## 3.0.0 — requires accounts 1.2.0\n- Sign in with your church account\n## 2.2.0\n- Moved into the monorepo',
|
||||
'apps/accounts/WHATS-NEW.md': '## 1.2.0\n- Authenticator app',
|
||||
'apps/website/WHATS-NEW.md': '## 1.0.0 — requires events 2.4.0\n- First release',
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const versions = product => mockReleases.filter(r => r.product === product).map(r => r.version).sort();
|
||||
|
||||
describe('sources', () => {
|
||||
test('the defaults: every product from the monorepo, plus Cross Events from the repo set before 2.0', () => {
|
||||
expect(defaultSources(mockSettings.values)).toEqual([
|
||||
{ product: 'events', repo: PLATFORM_REPO, tagPrefix: 'events@', notesPath: 'apps/events/WHATS-NEW.md' },
|
||||
{ product: 'events', repo: LEGACY, tagPrefix: 'v', notesPath: 'WHATS-NEW.md' },
|
||||
{ product: 'accounts', repo: PLATFORM_REPO, tagPrefix: 'accounts@', notesPath: 'apps/accounts/WHATS-NEW.md' },
|
||||
{ product: 'website', repo: PLATFORM_REPO, tagPrefix: 'website@', notesPath: 'apps/website/WHATS-NEW.md' },
|
||||
{ product: 'app', repo: PLATFORM_REPO, tagPrefix: 'app@', notesPath: 'apps/app/WHATS-NEW.md' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('a saved list replaces the defaults', () => {
|
||||
const saved = [{ product: 'events', repo: LEGACY, tagPrefix: 'v', notesPath: 'WHATS-NEW.md' }];
|
||||
expect(releaseSources({ release_sources: JSON.stringify(saved) })).toEqual(saved);
|
||||
});
|
||||
|
||||
test('bad sources are refused with what is wrong', () => {
|
||||
expect(() => cleanSources([{ product: 'shop', repo: LEGACY }])).toThrow(/product/);
|
||||
expect(() => cleanSources([{ product: 'events', repo: 'not a url' }])).toThrow(/repository/);
|
||||
expect(() => cleanSources([{ product: 'events', repo: LEGACY, tagPrefix: 'a b' }])).toThrow(/prefix/);
|
||||
expect(() => cleanSources([{ product: 'events', repo: LEGACY, notesPath: '../x' }])).toThrow(/notes/);
|
||||
expect(() => cleanSources([{ product: 'events', repo: LEGACY, tagPrefix: 'v' }, { product: 'events', repo: `${LEGACY}.git`, tagPrefix: 'v' }])).toThrow(/twice/);
|
||||
});
|
||||
|
||||
test('tag patterns: a prefix, and v (also bare versions, as before 2.0)', () => {
|
||||
expect(tagPattern('events@').exec('events@2.2.0')[1]).toBe('2.2.0');
|
||||
expect(tagPattern('events@').exec('website@2.2.0')).toBeNull();
|
||||
expect(tagPattern('events@').exec('events@2.2.0-rc1')).toBeNull();
|
||||
expect(tagPattern('v').exec('v2.1.1')[1]).toBe('2.1.1');
|
||||
expect(tagPattern('v').exec('2.1.1')[1]).toBe('2.1.1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('requirements in the notes', () => {
|
||||
test('"— requires accounts 1.2.0, website v1.1.0 — urgent"', () => {
|
||||
expect(parseNotes('## 3.0.0 — requires accounts 1.2.0, website v1.1.0 — urgent\n- x')['3.0.0']).toEqual({
|
||||
notes: '- x', urgent: true, requires: [{ product: 'accounts', version: '1.2.0' }, { product: 'website', version: '1.1.0' }],
|
||||
});
|
||||
});
|
||||
|
||||
test('no "requires" means no requirements, even if a product is named', () => {
|
||||
expect(parseRequirements(' — works with the website 1.0.0')).toEqual([]);
|
||||
expect(parseNotes('## 2.4.0\n- x')['2.4.0'].requires).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sync', () => {
|
||||
test('every product gets the tags of its sources, with notes and requirements', async () => {
|
||||
const result = await syncReleases();
|
||||
expect(versions('events')).toEqual(['2.0.0', '2.1.0', '2.1.1', '2.2.0', '3.0.0']);
|
||||
expect(versions('accounts')).toEqual(['1.2.0']);
|
||||
expect(versions('website')).toEqual(['1.0.0']);
|
||||
expect(versions('app')).toEqual([]);
|
||||
expect(mockReleases.find(r => r.product === 'events' && r.version === '3.0.0').requires).toEqual([{ product: 'accounts', version: '1.2.0' }]);
|
||||
expect(mockReleases.find(r => r.product === 'events' && r.version === '2.1.1').notes).toBe('- Feedback in the background');
|
||||
expect(result.latest).toEqual({ events: '3.0.0', accounts: '1.2.0', website: '1.0.0' });
|
||||
expect(mockSettings.values.latest_version).toBe('3.0.0');
|
||||
});
|
||||
|
||||
test('contracts@ tags are nobody\'s release', async () => {
|
||||
await syncReleases();
|
||||
expect(mockReleases.some(r => r.version === '1.1.0')).toBe(false);
|
||||
});
|
||||
|
||||
test('a removed tag removes its release', async () => {
|
||||
await syncReleases();
|
||||
gitea['hope-events'].tags = ['v2.1.0', 'v2.1.1'];
|
||||
const result = await syncReleases();
|
||||
expect(versions('events')).toEqual(['2.1.0', '2.1.1', '2.2.0', '3.0.0']);
|
||||
expect(result.removed).toBe(1);
|
||||
});
|
||||
|
||||
test('a source that can\'t be reached keeps its product\'s releases', async () => {
|
||||
await syncReleases();
|
||||
gitea['hope-events'] = 'down';
|
||||
const result = await syncReleases();
|
||||
expect(versions('events')).toEqual(['2.0.0', '2.1.0', '2.1.1', '2.2.0', '3.0.0']);
|
||||
expect(result.problems.join(' ')).toMatch(/hope-events.*ECONNREFUSED/);
|
||||
// The other products still sync.
|
||||
gitea['crosscode-platform'].tags.push('accounts@1.3.0');
|
||||
await syncReleases();
|
||||
expect(versions('accounts')).toEqual(['1.2.0', '1.3.0']);
|
||||
});
|
||||
|
||||
test('a product whose sources have no tags any more keeps its releases (and says so)', async () => {
|
||||
mockSettings.values.release_sources = JSON.stringify([{ product: 'events', repo: LEGACY, tagPrefix: 'v', notesPath: 'WHATS-NEW.md' }]);
|
||||
await syncReleases();
|
||||
gitea['hope-events'].tags = [];
|
||||
const result = await syncReleases();
|
||||
expect(versions('events')).toEqual(['2.0.0', '2.1.0', '2.1.1']);
|
||||
expect(result.problems.join(' ')).toMatch(/kept/);
|
||||
});
|
||||
|
||||
test('when nothing can be read, the sync fails and changes nothing', async () => {
|
||||
await syncReleases();
|
||||
gitea['hope-events'] = 'down';
|
||||
gitea['crosscode-platform'] = 'down';
|
||||
await expect(syncReleases()).rejects.toThrow(/ECONNREFUSED/);
|
||||
expect(versions('events')).toHaveLength(5);
|
||||
});
|
||||
|
||||
test('a product with no source is left alone (managed by hand)', async () => {
|
||||
mockReleases.push({ id: 'manual', product: 'app', version: '0.9.0', notes: '', urgent: false, requires: [], releasedAt: new Date() });
|
||||
mockSettings.values.release_sources = JSON.stringify([{ product: 'events', repo: LEGACY, tagPrefix: 'v', notesPath: 'WHATS-NEW.md' }]);
|
||||
await syncReleases();
|
||||
expect(versions('app')).toEqual(['0.9.0']);
|
||||
});
|
||||
|
||||
test('a requirement can\'t be on the product itself', async () => {
|
||||
gitea['crosscode-platform'].files['apps/events/WHATS-NEW.md'] = '## 3.0.0 — requires events 2.9.0, accounts 1.2.0\n- x';
|
||||
await syncReleases();
|
||||
expect(mockReleases.find(r => r.product === 'events' && r.version === '3.0.0').requires).toEqual([{ product: 'accounts', version: '1.2.0' }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('unmet requirements', () => {
|
||||
const releases = [
|
||||
{ version: '2.4.0', requires: [] },
|
||||
{ version: '2.5.0', requires: [{ product: 'accounts', version: '1.1.0' }] },
|
||||
{ version: '3.0.0', requires: [{ product: 'accounts', version: '1.2.0' }, { product: 'website', version: '1.0.0' }] },
|
||||
{ version: '3.1.0', requires: [{ product: 'accounts', version: '1.5.0' }] },
|
||||
];
|
||||
|
||||
test('the highest requirement over every release up to the target counts', () => {
|
||||
expect(unmetRequirements({ releases, from: '2.4.0', target: '3.0.0', siblings: [{ product: 'accounts', version: '1.1.0' }] })).toEqual([
|
||||
{ product: 'accounts', version: '1.2.0', current: '1.1.0' },
|
||||
{ product: 'website', version: '1.0.0', current: null },
|
||||
]);
|
||||
});
|
||||
|
||||
test('releases already installed, or beyond the target, don\'t count', () => {
|
||||
expect(unmetRequirements({ releases, from: '2.5.0', target: '2.5.0', siblings: [] })).toEqual([]);
|
||||
expect(unmetRequirements({ releases, from: '3.0.0', target: '3.1.0', siblings: [{ product: 'accounts', version: '1.5.0' }] })).toEqual([]);
|
||||
});
|
||||
|
||||
test('met when the sibling runs that version or later', () => {
|
||||
expect(unmetRequirements({ releases, from: '2.4.0', target: '3.0.0', siblings: [{ product: 'accounts', version: '1.2.1' }, { product: 'website', version: '1.0.0' }] })).toEqual([]);
|
||||
});
|
||||
|
||||
test('latest per product', () => {
|
||||
expect(latestByProduct([{ product: 'events', version: '2.10.0' }, { product: 'events', version: '2.9.0' }, { product: 'app', version: '1.0.0' }])).toEqual({ events: '2.10.0', app: '1.0.0' });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user