Skip to content

Commit bcba7a5

Browse files
committed
fix test
1 parent f916578 commit bcba7a5

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

src/vs/platform/backup/electron-main/backupMainService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export class BackupMainService implements IBackupMainService {
252252
// Validate Workspaces
253253
for (let workspace of rootWorkspaces) {
254254
if (!isWorkspaceIdentifier(workspace)) {
255+
console.log('not a workspace identifer');
255256
return []; // wrong format, skip all entries
256257
}
257258

@@ -266,10 +267,12 @@ export class BackupMainService implements IBackupMainService {
266267
if (workspace.configPath.scheme !== Schemas.file || await exists(workspace.configPath.fsPath)) {
267268
result.push(workspace);
268269
} else {
270+
console.log('target workspace missing');
269271
// If the workspace has backups, but the target workspace is missing, convert backups to empty ones
270272
await this.convertToEmptyWindowBackup(backupPath);
271273
}
272274
} else {
275+
console.log('no backups');
273276
await this.deleteStaleBackup(backupPath);
274277
}
275278
}

src/vs/platform/backup/test/electron-main/backupMainService.test.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -296,31 +296,23 @@ suite('BackupMainService', () => {
296296

297297
test('migrate storage file', async () => {
298298
let folderPath = path.join(parentDir, 'f1');
299+
ensureFolderExists(URI.file(folderPath));
299300
const backupFolderPath = service.toLegacyBackupPath(folderPath);
300-
if (!fs.existsSync(backupFolderPath)) {
301-
fs.mkdirSync(backupFolderPath);
302-
fs.mkdirSync(path.join(backupFolderPath, Schemas.file));
303-
await pfs.writeFile(path.join(backupFolderPath, Schemas.file, 'unsaved1.txt'), 'Legacy');
304-
}
301+
await createBackupFolder(backupFolderPath);
305302

306303
let workspacePath = path.join(parentDir, 'f2.code-workspace');
307304
const workspace = toWorkspace(workspacePath);
308-
309-
const backupWorkspacePath = service.toBackupPath(workspace.id);
310-
if (!fs.existsSync(backupWorkspacePath)) {
311-
fs.mkdirSync(backupWorkspacePath);
312-
fs.mkdirSync(path.join(backupWorkspacePath, Schemas.file));
313-
await pfs.writeFile(path.join(backupWorkspacePath, Schemas.file, 'unsaved2.txt'), 'Legacy');
314-
}
315-
305+
await ensureWorkspaceExists(workspace);
316306

317307
const workspacesJson = { rootWorkspaces: [{ id: workspace.id, configPath: workspacePath }], folderWorkspaces: [folderPath], emptyWorkspaces: [] };
318308
await pfs.writeFile(backupWorkspacesPath, JSON.stringify(workspacesJson));
319309
await service.initialize();
320310
const content = await pfs.readFile(backupWorkspacesPath, 'utf-8');
321311
const json = (<IBackupWorkspacesFormat>JSON.parse(content));
322312
assert.deepEqual(json.folderURIWorkspaces, [URI.file(folderPath).toString()]);
323-
assert.deepEqual(json.rootURIWorkspaces, [{ id: workspace.id, configPath: URI.file(workspacePath).toString() }]);
313+
assert.deepEqual(json.rootURIWorkspaces, [{ id: workspace.id, configURIPath: URI.file(workspacePath).toString() }]);
314+
315+
assertEqualUris(service.getWorkspaceBackups().map(w => w.configPath), [workspace.configPath]);
324316
});
325317
});
326318

0 commit comments

Comments
 (0)