-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.test.ts
More file actions
74 lines (66 loc) · 2.75 KB
/
Copy pathcli.test.ts
File metadata and controls
74 lines (66 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { execFileSync } from 'child_process';
import * as https from 'https';
import { afterEach, describe, expect, it } from 'vitest';
import {
githubReleaseExistsViaHttps,
setHttpsGetForTests,
} from './compatibility/verify_matrix';
const root = __dirname;
function runTsScript(script: string): string {
return execFileSync('npx', ['ts-node', script], {
cwd: root,
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'pipe'],
});
}
function mockHttpsGet(statusCode: number): typeof https.get {
return (_url, _opts, cb) => {
const res = {
statusCode,
resume: () => undefined,
on: (event: string, handler: () => void) => {
if (event === 'end') {
handler();
}
},
};
(cb as (res: typeof res) => void)(res);
return {
on: () => undefined,
setTimeout: (_ms: number, handler: () => void) => {
handler();
return undefined;
},
destroy: () => undefined,
} as unknown as ReturnType<typeof https.get>;
};
}
afterEach(() => {
setHttpsGetForTests(null);
});
describe('CLI entrypoints', () => {
it('runs conformance and validation scripts successfully', () => {
expect(runTsScript('conformance/runner.ts')).toContain('All conformance checks passed');
expect(runTsScript('conformance/jcs_conformance.ts')).toContain('All JCS conformance checks passed');
expect(runTsScript('conformance/agent_manifest_test.ts')).toContain('All agent manifest projection checks passed');
expect(runTsScript('conformance/webhook_findings.ts')).toContain('All webhook finding signature checks passed');
expect(runTsScript('conformance/stripe_demo_fixtures.ts')).toContain(
'All stripe@demo golden fixture checks passed',
);
expect(runTsScript('integrity/verify_manifest.ts')).toContain('All integrity checks passed');
expect(runTsScript('compatibility/verify_matrix.ts')).toContain('Compatibility matrix schema validated');
expect(runTsScript('semantics/validate_reasons.ts')).toContain('reasons.json:');
expect(runTsScript('semantics/validate_provenance_classes.ts')).toContain('Validated');
expect(runTsScript('reference-policies/validate.ts')).toContain('Reference policy validation passed');
});
});
describe('githubReleaseExistsViaHttps', () => {
it('handles github release lookup responses', async () => {
setHttpsGetForTests(mockHttpsGet(200));
await expect(githubReleaseExistsViaHttps('intentproof-spec', 'v1.0.0')).resolves.toBe(true);
setHttpsGetForTests(mockHttpsGet(404));
await expect(githubReleaseExistsViaHttps('intentproof-spec', 'missing')).resolves.toBe(false);
setHttpsGetForTests(mockHttpsGet(500));
await expect(githubReleaseExistsViaHttps('intentproof-spec', 'v1.0.0')).rejects.toThrow(/HTTP 500/);
});
});