query test progress
This commit is contained in:
58
migrate_fixtures.js
Normal file
58
migrate_fixtures.js
Normal file
@ -0,0 +1,58 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const fixturesDir = path.join(__dirname, 'tests', 'fixtures');
|
||||
|
||||
function processFile(filePath) {
|
||||
const content = fs.readFileSync(filePath, 'utf8');
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(content);
|
||||
} catch (e) {
|
||||
console.error(`Skipping ${filePath} due to parse error`);
|
||||
return;
|
||||
}
|
||||
|
||||
let modified = false;
|
||||
|
||||
data.forEach(suite => {
|
||||
if (suite.tests) {
|
||||
suite.tests.forEach(test => {
|
||||
if (test.valid !== undefined || test.expect_errors !== undefined) {
|
||||
if (!test.expect) {
|
||||
test.expect = {};
|
||||
}
|
||||
if (test.valid !== undefined) {
|
||||
test.expect.success = test.valid;
|
||||
delete test.valid;
|
||||
}
|
||||
if (test.expect_errors !== undefined) {
|
||||
test.expect.errors = test.expect_errors;
|
||||
delete test.expect_errors;
|
||||
}
|
||||
modified = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (modified) {
|
||||
fs.writeFileSync(filePath, JSON.stringify(data, null, 4));
|
||||
console.log(`Migrated ${filePath}`);
|
||||
}
|
||||
}
|
||||
|
||||
function walkDir(dir) {
|
||||
const files = fs.readdirSync(dir);
|
||||
files.forEach(file => {
|
||||
const fullPath = path.join(dir, file);
|
||||
if (fs.statSync(fullPath).isDirectory()) {
|
||||
walkDir(fullPath);
|
||||
} else if (fullPath.endsWith('.json')) {
|
||||
processFile(fullPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
walkDir(fixturesDir);
|
||||
console.log('Done migrating fixtures!');
|
||||
Reference in New Issue
Block a user