|
1 | 1 | import { describe, expect, it } from 'bun:test' |
2 | | -import { pantryLockViolations } from '../src/pantry-lock' |
| 2 | +import { pantryLockViolations, preservePantrySystemPins } from '../src/pantry-lock' |
3 | 3 |
|
4 | 4 | /** |
5 | 5 | * The release guard for `pantry.lock` (stacksjs/stacks#2843). |
@@ -38,6 +38,34 @@ const lockOf = (value: unknown) => JSON.stringify(value) |
38 | 38 | const committed = lockOf(sound) |
39 | 39 | const clone = () => JSON.parse(committed) as typeof sound |
40 | 40 |
|
| 41 | +describe('release native toolchain pins', () => { |
| 42 | + const previous = { ...sound, packages: { ...sound.packages, |
| 43 | + 'libexpat.github.io@2.10.0': { name: 'libexpat.github.io', version: '2.10.0', source: 'pantry' }, |
| 44 | + } } |
| 45 | + const regenerated = { ...sound, packages: { |
| 46 | + 'pickier@0.1.66': { name: 'pickier', version: '0.1.66' }, |
| 47 | + 'libexpat.github.io@2.9.0': { name: 'libexpat.github.io', version: '2.9.0', source: 'pantry' }, |
| 48 | + } } |
| 49 | + |
| 50 | + it('keeps the validated system graph while refreshing JS resolutions', () => { |
| 51 | + const result = JSON.parse(preservePantrySystemPins(lockOf(regenerated), lockOf(previous))) |
| 52 | + expect(result.packages['libexpat.github.io@2.10.0'].version).toBe('2.10.0') |
| 53 | + expect(result.packages['libexpat.github.io@2.9.0']).toBeUndefined() |
| 54 | + expect(result.packages['pickier@0.1.66'].version).toBe('0.1.66') |
| 55 | + expect(result.packages['pickier@0.1.65']).toBeUndefined() |
| 56 | + }) |
| 57 | + |
| 58 | + it('allows an intentional native toolchain declaration change', () => { |
| 59 | + const changed = JSON.parse(lockOf(regenerated)) |
| 60 | + changed.workspaces[''].system['bun.sh'] = '1.4.3' |
| 61 | + expect(preservePantrySystemPins(lockOf(changed), lockOf(previous))).toBe(lockOf(changed)) |
| 62 | + }) |
| 63 | + |
| 64 | + it('does not invent a system graph for projects that declared none', () => { |
| 65 | + expect(preservePantrySystemPins(lockOf(regenerated), '{"packages":{}}')).toBe(lockOf(regenerated)) |
| 66 | + }) |
| 67 | +}) |
| 68 | + |
41 | 69 | describe('pantryLockViolations', () => { |
42 | 70 | it('rejects a self-consistent lock that still records the previous release declarations', () => { |
43 | 71 | const expected = clone().workspaces |
|
0 commit comments