26 lines
917 B
JavaScript
26 lines
917 B
JavaScript
import assert from 'assert';
|
|
import { fileURLToPath } from 'url';
|
|
import path from 'path';
|
|
import { execFileSync } from 'child_process';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
const fixturesDir = path.join(__dirname, '__fixtures__', 'api-compat');
|
|
const oldSpec = path.join(fixturesDir, 'old.yaml');
|
|
const newSpec = path.join(fixturesDir, 'new.yaml');
|
|
|
|
const output = execFileSync('node', ['scripts/api-compat-diff.mjs', oldSpec, newSpec, '--output', 'json'], {
|
|
cwd: path.join(__dirname, '..'),
|
|
encoding: 'utf8',
|
|
});
|
|
|
|
const diff = JSON.parse(output);
|
|
|
|
assert.deepStrictEqual(diff.additive.operations, ['get /bar']);
|
|
assert.deepStrictEqual(diff.breaking.operations, []);
|
|
assert.deepStrictEqual(diff.additive.responses, ['get /foo -> 201']);
|
|
assert.deepStrictEqual(diff.breaking.responses, ['get /foo -> 200']);
|
|
|
|
console.log('api-compat-diff test passed');
|