Skip to content

Commit

Permalink
#140088 fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jan 11, 2022
1 parent 1471a85 commit f0e8b65
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { joinPath } from 'vs/base/common/resources';
import { VSBuffer } from 'vs/base/common/buffer';
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { migrateExtensionStorage } from 'vs/workbench/services/extensions/common/extensionStorageMigration';
import { generateUuid } from 'vs/base/common/uuid';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';

suite('ExtensionStorageMigration', () => {
Expand All @@ -43,15 +42,15 @@ suite('ExtensionStorageMigration', () => {
teardown(() => disposables.clear());

test('migrate extension storage', async () => {
const fromExtensionId = 'pub.from', toExtensionId = 'pub.to', storageMigratedKey = generateUuid();
const fromExtensionId = 'pub.from', toExtensionId = 'pub.to', storageMigratedKey = `extensionStorage.migrate.${fromExtensionId}-${toExtensionId}`;
const extensionStorageService = instantiationService.get(IExtensionStorageService), fileService = instantiationService.get(IFileService), storageService = instantiationService.get(IStorageService);

extensionStorageService.setExtensionState(fromExtensionId, { globalKey: 'hello global state' }, true);
extensionStorageService.setExtensionState(fromExtensionId, { workspaceKey: 'hello workspace state' }, false);
await fileService.writeFile(joinPath(globalStorageHome, fromExtensionId), VSBuffer.fromString('hello global storage'));
await fileService.writeFile(joinPath(workspaceStorageHome, TestWorkspace.id, fromExtensionId), VSBuffer.fromString('hello workspace storage'));

await migrateExtensionStorage(fromExtensionId, toExtensionId, storageMigratedKey, instantiationService);
await migrateExtensionStorage(fromExtensionId, toExtensionId, instantiationService);

assert.deepStrictEqual(extensionStorageService.getExtensionState(fromExtensionId, true), undefined);
assert.deepStrictEqual(extensionStorageService.getExtensionState(fromExtensionId, false), undefined);
Expand All @@ -69,10 +68,10 @@ suite('ExtensionStorageMigration', () => {
});

test('migrate extension storage when does not exist', async () => {
const fromExtensionId = 'pub.from', toExtensionId = 'pub.to', storageMigratedKey = generateUuid();
const fromExtensionId = 'pub.from', toExtensionId = 'pub.to', storageMigratedKey = `extensionStorage.migrate.${fromExtensionId}-${toExtensionId}`;
const extensionStorageService = instantiationService.get(IExtensionStorageService), fileService = instantiationService.get(IFileService), storageService = instantiationService.get(IStorageService);

await migrateExtensionStorage(fromExtensionId, toExtensionId, storageMigratedKey, instantiationService);
await migrateExtensionStorage(fromExtensionId, toExtensionId, instantiationService);

assert.deepStrictEqual(extensionStorageService.getExtensionState(fromExtensionId, true), undefined);
assert.deepStrictEqual(extensionStorageService.getExtensionState(fromExtensionId, false), undefined);
Expand Down

0 comments on commit f0e8b65

Please sign in to comment.