test(aio): fix preview server tests on Windows

This commit is contained in:
Georgios Kalpakas 2017-06-17 21:22:44 +03:00 committed by Matias Niemelä
parent 1b13bdea4b
commit 3112311134
2 changed files with 13 additions and 11 deletions

View File

@ -1,5 +1,6 @@
// Imports // Imports
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path';
import * as shell from 'shelljs'; import * as shell from 'shelljs';
import {BuildCleaner} from '../../lib/clean-up/build-cleaner'; import {BuildCleaner} from '../../lib/clean-up/build-cleaner';
import {GithubPullRequests} from '../../lib/common/github-pull-requests'; import {GithubPullRequests} from '../../lib/common/github-pull-requests';
@ -287,17 +288,17 @@ describe('BuildCleaner', () => {
it('should construct full paths to directories (by prepending \'buildsDir\')', () => { it('should construct full paths to directories (by prepending \'buildsDir\')', () => {
(cleaner as any).removeUnnecessaryBuilds([1, 2, 3], []); (cleaner as any).removeUnnecessaryBuilds([1, 2, 3], []);
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith('/foo/bar/1'); expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(path.normalize('/foo/bar/1'));
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith('/foo/bar/2'); expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(path.normalize('/foo/bar/2'));
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith('/foo/bar/3'); expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(path.normalize('/foo/bar/3'));
}); });
it('should remove the builds that do not correspond to open PRs', () => { it('should remove the builds that do not correspond to open PRs', () => {
(cleaner as any).removeUnnecessaryBuilds([1, 2, 3, 4], [2, 4]); (cleaner as any).removeUnnecessaryBuilds([1, 2, 3, 4], [2, 4]);
expect(cleanerRemoveDirSpy).toHaveBeenCalledTimes(2); expect(cleanerRemoveDirSpy).toHaveBeenCalledTimes(2);
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith('/foo/bar/1'); expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(path.normalize('/foo/bar/1'));
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith('/foo/bar/3'); expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(path.normalize('/foo/bar/3'));
cleanerRemoveDirSpy.calls.reset(); cleanerRemoveDirSpy.calls.reset();
(cleaner as any).removeUnnecessaryBuilds([1, 2, 3, 4], [1, 2, 3, 4]); (cleaner as any).removeUnnecessaryBuilds([1, 2, 3, 4], [1, 2, 3, 4]);
@ -306,10 +307,10 @@ describe('BuildCleaner', () => {
(cleaner as any).removeUnnecessaryBuilds([1, 2, 3, 4], []); (cleaner as any).removeUnnecessaryBuilds([1, 2, 3, 4], []);
expect(cleanerRemoveDirSpy).toHaveBeenCalledTimes(4); expect(cleanerRemoveDirSpy).toHaveBeenCalledTimes(4);
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith('/foo/bar/1'); expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(path.normalize('/foo/bar/1'));
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith('/foo/bar/2'); expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(path.normalize('/foo/bar/2'));
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith('/foo/bar/3'); expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(path.normalize('/foo/bar/3'));
expect(cleanerRemoveDirSpy).toHaveBeenCalledWith('/foo/bar/4'); expect(cleanerRemoveDirSpy).toHaveBeenCalledWith(path.normalize('/foo/bar/4'));
cleanerRemoveDirSpy.calls.reset(); cleanerRemoveDirSpy.calls.reset();
}); });

View File

@ -2,6 +2,7 @@
import * as cp from 'child_process'; import * as cp from 'child_process';
import {EventEmitter} from 'events'; import {EventEmitter} from 'events';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path';
import * as shell from 'shelljs'; import * as shell from 'shelljs';
import {BuildCreator} from '../../lib/upload-server/build-creator'; import {BuildCreator} from '../../lib/upload-server/build-creator';
import {CreatedBuildEvent} from '../../lib/upload-server/build-events'; import {CreatedBuildEvent} from '../../lib/upload-server/build-events';
@ -14,8 +15,8 @@ describe('BuildCreator', () => {
const sha = '9'.repeat(40); const sha = '9'.repeat(40);
const archive = 'snapshot.tar.gz'; const archive = 'snapshot.tar.gz';
const buildsDir = 'builds/dir'; const buildsDir = 'builds/dir';
const prDir = `${buildsDir}/${pr}`; const prDir = path.join(buildsDir, pr);
const shaDir = `${prDir}/${sha}`; const shaDir = path.join(prDir, sha);
let bc: BuildCreator; let bc: BuildCreator;
beforeEach(() => bc = new BuildCreator(buildsDir)); beforeEach(() => bc = new BuildCreator(buildsDir));