Skip to content

Commit

Permalink
Fix service.test.ts to stop disposing of all services (microsoft#21811
Browse files Browse the repository at this point in the history
)

file `service.test.ts` was calling to dispose of all items related to
the service container for clean up. This led to services in later tests
failing since they were close already. Fixes here allow for new tests in
the test adapter to be written.

fix helps microsoft#21803
  • Loading branch information
eleanorjboyd authored and anthonykim1 committed Sep 12, 2023
1 parent 387dc3c commit c35b6a3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/test/common/configuration/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Licensed under the MIT License.
import { expect } from 'chai';
import { workspace } from 'vscode';
import { IConfigurationService, IDisposableRegistry } from '../../../client/common/types';
import { disposeAll } from '../../../client/common/utils/resourceLifecycle';
import { IConfigurationService, IDisposableRegistry, IExtensionContext } from '../../../client/common/types';
import { IServiceContainer } from '../../../client/ioc/types';
import { getExtensionSettings } from '../../extensionSettings';
import { initialize } from '../../initialize';
Expand All @@ -23,15 +22,17 @@ suite('Configuration Service', () => {

test('Ensure async registry works', async () => {
const asyncRegistry = serviceContainer.get<IDisposableRegistry>(IDisposableRegistry);
let disposed = false;
let subs = serviceContainer.get<IExtensionContext>(IExtensionContext).subscriptions;
const oldLength = subs.length;
const disposable = {
dispose(): Promise<void> {
disposed = true;
return Promise.resolve();
},
};
asyncRegistry.push(disposable);
await disposeAll(asyncRegistry);
expect(disposed).to.be.equal(true, "Didn't dispose during async registry cleanup");
subs = serviceContainer.get<IExtensionContext>(IExtensionContext).subscriptions;
const newLength = subs.length;
expect(newLength).to.be.equal(oldLength + 1, 'Subscription not added');
// serviceContainer subscriptions are not disposed of as this breaks other tests that use the service container.
});
});

0 comments on commit c35b6a3

Please sign in to comment.