GitNexus/gitnexus/test/unit/move/discovery.test.ts
zwxxb 40abd33325 fix(move): track compiler identity for managed move-flow installs
Verify managed installs against release checksums, serialize them with
a cross-process lock, and record the compiler identity that produced
the Move graph so a compiler change forces a full rebuild. Fail closed
when the existing Move graph needs a compiler that is unavailable.
2026-07-21 21:35:34 +02:00

35 lines
1 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from 'vitest';
vi.mock('glob', () => ({ globIterate: vi.fn() }));
import { globIterate } from 'glob';
import { repoHasMove } from '../../../src/core/move/discovery.js';
const mockGlobIterate = vi.mocked(globIterate);
const results = async function* (values: string[]): AsyncGenerator<string> {
yield* values;
};
describe('repoHasMove', () => {
beforeEach(() => {
mockGlobIterate.mockReset();
});
it('distinguishes an empty repository from a discovery failure', async () => {
mockGlobIterate.mockReturnValueOnce(results([])).mockReturnValueOnce(
(async function* () {
throw new Error('permission denied');
})(),
);
await expect(repoHasMove('/repo')).resolves.toBe(false);
await expect(repoHasMove('/repo')).rejects.toThrow('permission denied');
});
it('reports Move when a manifest is found', async () => {
mockGlobIterate.mockReturnValue(results(['contracts/Move.toml']));
await expect(repoHasMove('/repo')).resolves.toBe(true);
});
});