mirror of
https://github.com/HeyPuter/puter.git
synced 2025-01-23 06:00:21 +08:00
dev: add cartesian case selector
This commit is contained in:
parent
405d9b35aa
commit
dd86724941
@ -3,7 +3,3 @@
|
||||
1. run `npm install`
|
||||
2. copy `example_config.yml` and add the correct values
|
||||
3. run `node apitest.js --config=your_config_file.yml`
|
||||
|
||||
## Here's what it looks like when it's working
|
||||
|
||||
![image](https://github.com/HeyPuter/puter-api-test/assets/7225168/115aca70-02ea-4ce1-9d5c-1568feb1f851)
|
||||
|
@ -12,12 +12,7 @@ const args = process.argv.slice(2);
|
||||
let config, report;
|
||||
|
||||
try {
|
||||
({ values: {
|
||||
config,
|
||||
report,
|
||||
bench,
|
||||
unit,
|
||||
}, positionals: [id] } = parseArgs({
|
||||
const parsed = parseArgs({
|
||||
options: {
|
||||
config: {
|
||||
type: 'string',
|
||||
@ -25,31 +20,45 @@ try {
|
||||
report: {
|
||||
type: 'string',
|
||||
},
|
||||
onlycase: { type: 'string' },
|
||||
bench: { type: 'boolean' },
|
||||
unit: { type: 'boolean' },
|
||||
},
|
||||
allowPositionals: true,
|
||||
}));
|
||||
} catch (e) {
|
||||
if ( args.length < 1 ) {
|
||||
console.error(
|
||||
'Usage: apitest [OPTIONS]\n' +
|
||||
'\n' +
|
||||
'Options:\n' +
|
||||
' --config=<path> (required) Path to configuration file\n' +
|
||||
' --report=<path> (optional) Output file for full test results\n' +
|
||||
''
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
({ values: {
|
||||
config,
|
||||
report,
|
||||
onlycase,
|
||||
bench,
|
||||
unit,
|
||||
}, positionals: [id] } = parsed);
|
||||
|
||||
onlycase = Number.parseInt(onlycase);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
console.error(
|
||||
'Usage: apitest [OPTIONS]\n' +
|
||||
'\n' +
|
||||
'Options:\n' +
|
||||
' --config=<path> (required) Path to configuration file\n' +
|
||||
' --report=<path> (optional) Output file for full test results\n' +
|
||||
''
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const conf = YAML.parse(fs.readFileSync(config).toString());
|
||||
|
||||
|
||||
const main = async () => {
|
||||
const ts = new TestSDK(conf);
|
||||
const context = {
|
||||
options: {
|
||||
onlycase,
|
||||
}
|
||||
};
|
||||
const ts = new TestSDK(conf, context);
|
||||
try {
|
||||
await ts.delete('api_test', { recursive: true });
|
||||
} catch (e) {
|
||||
|
@ -12,6 +12,12 @@ module.exports = class TestFactory {
|
||||
for ( let i=0 ; i < states.length ; i++ ) {
|
||||
const state = states[i];
|
||||
|
||||
if ( t.context.options.onlycase !== undefined ) {
|
||||
if ( i !== t.context.options.onlycase ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
await t.case(`case ${i}`, async () => {
|
||||
console.log('state', state);
|
||||
await each(t, state, i);
|
||||
|
@ -9,8 +9,9 @@ const Assert = require('./Assert');
|
||||
const log_error = require('./log_error');
|
||||
|
||||
module.exports = class TestSDK {
|
||||
constructor (conf) {
|
||||
constructor (conf, context) {
|
||||
this.conf = conf;
|
||||
this.context = context;
|
||||
this.cwd = `/${conf.username}`;
|
||||
this.httpsAgent = new https.Agent({
|
||||
rejectUnauthorized: false
|
||||
@ -100,7 +101,7 @@ module.exports = class TestSDK {
|
||||
process.stdout.write(strid + ' ... \n');
|
||||
|
||||
try {
|
||||
await fn();
|
||||
await fn(this.context);
|
||||
} catch (e) {
|
||||
process.stdout.write(`${tabs}...\x1B[31;1m[FAIL]\x1B[0m\n`);
|
||||
this.recordResult({
|
||||
|
Loading…
Reference in New Issue
Block a user