提交 ef4b5102 编写于 作者: D Daniel Imms

Fix tests

上级 eb9a79d4
......@@ -119,12 +119,16 @@ export class BackupMainService implements IBackupMainService {
this.validateBackupWorkspaces(backups);
}
private validateBackupWorkspaces(backups: IBackupWorkspacesFormat): void {
const staleBackupWorkspaces: { workspaceIdentifier: string; backupPath: string; isEmptyWorkspace: boolean }[] = [];
protected sanitizeFolderWorkspaces(backups: IBackupWorkspacesFormat): void {
// Merge duplicates for folder workspaces, don't worry about cleaning them up as they will
// be removed when there are no backups.
backups.folderWorkspaces = arrays.distinct(backups.folderWorkspaces.map(w => this.sanitizePath(w)));
}
private validateBackupWorkspaces(backups: IBackupWorkspacesFormat): void {
const staleBackupWorkspaces: { workspaceIdentifier: string; backupPath: string; isEmptyWorkspace: boolean }[] = [];
this.sanitizeFolderWorkspaces(backups);
backups.folderWorkspaces.forEach(workspacePath => {
const backupPath = path.join(this.backupHome, this.getWorkspaceHash(workspacePath));
......
......@@ -36,6 +36,10 @@ class TestBackupMainService extends BackupMainService {
super.loadSync();
}
public sanitizeFolderWorkspaces(backups: IBackupWorkspacesFormat): void {
super.sanitizeFolderWorkspaces(backups);
}
public toBackupPath(workspacePath: string): string {
return path.join(this.backupHome, super.getWorkspaceHash(workspacePath));
}
......@@ -72,8 +76,6 @@ suite('BackupMainService', () => {
test('service validates backup workspaces on startup and cleans up', done => {
// 1) backup workspace path does not exist
console.log('fooFile :' + fooFile.fsPath);
console.log('barFile :' + barFile.fsPath);
service.registerWindowForBackups(1, false, null, fooFile.fsPath);
service.registerWindowForBackups(2, false, null, barFile.fsPath);
service.loadSync();
......@@ -190,23 +192,26 @@ suite('BackupMainService', () => {
service.loadSync();
assert.deepEqual(service.emptyWorkspaceBackupPaths, []);
});
});
suite('sanitizeFolderWorkspaces', () => {
test('should merge same cased paths on Windows and Mac', () => {
// Skip test on Linux
if (platform.isLinux) {
return;
}
if (platform.isMacintosh) {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaces":["/foo", "/FOO"]}');
service.loadSync();
assert.deepEqual(service.workspaceBackupPaths, ['/foo']);
}
const backups: IBackupWorkspacesFormat = {
folderWorkspaces: platform.isWindows ? ['c:\\foo', 'C:\\FOO', 'c:\\FOO'] : ['/foo', '/FOO'],
emptyWorkspaces: []
};
service.sanitizeFolderWorkspaces(backups);
if (platform.isWindows) {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaces":["c:\\foo", "C:\\FOO", "c:\\FOO]}');
service.loadSync();
assert.deepEqual(service.workspaceBackupPaths, ['c:\\foo']);
assert.deepEqual(backups.folderWorkspaces, ['c:\\foo']);
} else {
assert.deepEqual(backups.folderWorkspaces, ['/foo']);
}
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册