2020-11-15 01:42:36 +03:00
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
2020-11-17 07:07:24 +03:00
|
|
|
import zlib from 'zlib';
|
2020-11-15 01:42:36 +03:00
|
|
|
|
|
|
|
export function saveTests(tag: string, data: any) {
|
|
|
|
let filename = path.resolve(__dirname, '../testcases', tag + '.json.gz');
|
|
|
|
|
|
|
|
fs.writeFileSync(filename, zlib.gzipSync(JSON.stringify(data, undefined, ' ') + '\n'));
|
|
|
|
|
|
|
|
console.log('Save testcase: ' + filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function loadTests<T = any>(tag: string): T {
|
|
|
|
let filename = path.resolve(__dirname, '../testcases', tag + '.json.gz');
|
|
|
|
return JSON.parse(zlib.gunzipSync(fs.readFileSync(filename)).toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
export function loadData(filename: string): Buffer {
|
|
|
|
return fs.readFileSync(path.resolve(__dirname, filename));
|
|
|
|
}
|