Skip to content

Commit bbf53ed

Browse files
committed
storage - use fake timers for clear test (microsoft#135075)
1 parent 3caab42 commit bbf53ed

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/vs/platform/storage/test/browser/storageService.test.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
88
import { Schemas } from 'vs/base/common/network';
99
import { Storage } from 'vs/base/parts/storage/common/storage';
1010
import { flakySuite } from 'vs/base/test/common/testUtils';
11+
import { runWithFakedTimers } from 'vs/base/test/common/timeTravelScheduler';
1112
import { FileService } from 'vs/platform/files/common/fileService';
1213
import { InMemoryFileSystemProvider } from 'vs/platform/files/common/inMemoryFilesystemProvider';
1314
import { NullLogService } from 'vs/platform/log/common/log';
@@ -67,19 +68,21 @@ flakySuite('StorageService (browser specific)', () => {
6768
});
6869

6970
test('clear', async () => {
70-
storageService.store('bar', 'foo', StorageScope.GLOBAL, StorageTarget.MACHINE);
71-
storageService.store('bar', 3, StorageScope.GLOBAL, StorageTarget.USER);
72-
storageService.store('bar', 'foo', StorageScope.WORKSPACE, StorageTarget.MACHINE);
73-
storageService.store('bar', 3, StorageScope.WORKSPACE, StorageTarget.USER);
71+
await runWithFakedTimers({ useFakeTimers: true }, async () => {
72+
storageService.store('bar', 'foo', StorageScope.GLOBAL, StorageTarget.MACHINE);
73+
storageService.store('bar', 3, StorageScope.GLOBAL, StorageTarget.USER);
74+
storageService.store('bar', 'foo', StorageScope.WORKSPACE, StorageTarget.MACHINE);
75+
storageService.store('bar', 3, StorageScope.WORKSPACE, StorageTarget.USER);
7476

75-
await storageService.clear();
77+
await storageService.clear();
7678

77-
for (const scope of [StorageScope.GLOBAL, StorageScope.WORKSPACE]) {
78-
for (const target of [StorageTarget.USER, StorageTarget.MACHINE]) {
79-
strictEqual(storageService.get('bar', scope), undefined);
80-
strictEqual(storageService.keys(scope, target).length, 0);
79+
for (const scope of [StorageScope.GLOBAL, StorageScope.WORKSPACE]) {
80+
for (const target of [StorageTarget.USER, StorageTarget.MACHINE]) {
81+
strictEqual(storageService.get('bar', scope), undefined);
82+
strictEqual(storageService.keys(scope, target).length, 0);
83+
}
8184
}
82-
}
85+
});
8386
});
8487
});
8588

0 commit comments

Comments
 (0)