Fix bug disconnecting during stuck OE operation (#2773)

This commit is contained in:
Matt Irvine
2018-10-08 15:42:13 -07:00
committed by GitHub
parent 0bd179c6ca
commit 4b79ecc3d9
3 changed files with 50 additions and 10 deletions

View File

@@ -447,10 +447,11 @@ suite('SQL Object Explorer Service tests', () => {
objectExplorerService.updateObjectExplorerNodes(connection).then(() => {
var treeNode = objectExplorerService.getObjectExplorerNode(connection);
assert.equal(treeNode !== null && treeNode !== undefined, true);
objectExplorerService.deleteObjectExplorerNode(connection);
treeNode = objectExplorerService.getObjectExplorerNode(connection);
assert.equal(treeNode === null || treeNode === undefined, true);
done();
objectExplorerService.deleteObjectExplorerNode(connection).then(() => {
treeNode = objectExplorerService.getObjectExplorerNode(connection);
assert.equal(treeNode === null || treeNode === undefined, true);
done();
});
}, err => {
// Must call done here so test indicates it's finished if errors occur
done(err);
@@ -754,6 +755,28 @@ suite('SQL Object Explorer Service tests', () => {
});
});
test('Session can be closed even if expand requests are pending', async () => {
const providerId = 'MSSQL';
// Set up the session
await objectExplorerService.createNewSession(providerId, connection);
objectExplorerService.onSessionCreated(1, objectExplorerSession);
// Set up the provider to not respond to the second expand request, simulating a request that takes a long time to complete
const nodePath = objectExplorerSession.rootNode.nodePath;
sqlOEProvider.setup(x => x.expandNode(TypeMoq.It.is(x => x.nodePath === nodePath))).callback(() => { }).returns(() => TPromise.as(true));
// If I queue a second expand request (the first completes normally because of the original mock) and then close the session
await objectExplorerService.expandNode(providerId, objectExplorerSession, objectExplorerSession.rootNode.nodePath);
let expandPromise = objectExplorerService.expandNode(providerId, objectExplorerSession, objectExplorerSession.rootNode.nodePath);
let closeSessionResult = await objectExplorerService.closeSession(providerId, objectExplorerSession);
// Then the expand request has completed and the session is closed
let expandResult = await expandPromise;
assert.equal(expandResult.nodes.length, 0);
assert.equal(closeSessionResult.success, true);
});
test('resolveTreeNodeChildren refreshes a node if it currently has an error', async () => {
await objectExplorerService.createNewSession('MSSQL', connection);
objectExplorerService.onSessionCreated(1, objectExplorerSession);