mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[dev] Update download.js tests to be "stateless" (#61525)
* Make download.js test stateless so it can be parallelized * Proper clean up etc * Use CI prefixes for tmp dir creation + export it
This commit is contained in:
parent
b1fa159e17
commit
714743d829
2 changed files with 23 additions and 9 deletions
|
@ -58,3 +58,5 @@ export {
|
|||
export { runFailedTestsReporterCli } from './failed_tests_reporter';
|
||||
|
||||
export { makeJunitReportPath } from './junit_report_path';
|
||||
|
||||
export { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix';
|
||||
|
|
|
@ -18,27 +18,39 @@
|
|||
*/
|
||||
|
||||
import { createServer } from 'http';
|
||||
import { resolve } from 'path';
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { tmpdir } from 'os';
|
||||
import { mkdirp, readFileSync } from 'fs-extra';
|
||||
|
||||
import del from 'del';
|
||||
import sinon from 'sinon';
|
||||
import { CI_PARALLEL_PROCESS_PREFIX } from '@kbn/test';
|
||||
import expect from '@kbn/expect';
|
||||
import Wreck from '@hapi/wreck';
|
||||
|
||||
import { ToolingLog } from '@kbn/dev-utils';
|
||||
import { download } from '../download';
|
||||
|
||||
const TMP_DESTINATION = resolve(__dirname, '__tmp__');
|
||||
beforeEach(async () => {
|
||||
await del(TMP_DESTINATION);
|
||||
});
|
||||
after(async () => {
|
||||
await del(TMP_DESTINATION);
|
||||
});
|
||||
const getTempFolder = async () => {
|
||||
const dir = join(tmpdir(), CI_PARALLEL_PROCESS_PREFIX, 'download-js-test-tmp-dir');
|
||||
console.log(dir);
|
||||
await mkdirp(dir);
|
||||
return dir;
|
||||
};
|
||||
|
||||
describe('src/dev/build/tasks/nodejs/download', () => {
|
||||
const sandbox = sinon.createSandbox();
|
||||
let TMP_DESTINATION;
|
||||
let TMP_DIR;
|
||||
|
||||
beforeEach(async () => {
|
||||
TMP_DIR = await getTempFolder();
|
||||
TMP_DESTINATION = join(TMP_DIR, '__tmp_download_js_test_file__');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await del(TMP_DIR, { force: true });
|
||||
});
|
||||
afterEach(() => sandbox.reset());
|
||||
|
||||
const onLogLine = sandbox.stub();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue