mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Implement Session support through the extension host (#3228)
Full plumb through of Session support. Also fixed some test issues - Load session and get necessary information in kernels list - Run Cell button now works as expected - Added a ToggleAction base class which can be used for anything that switches icons. I'd still prefer to have this be dynamic and as clean as the extension classes - Fixed account test unhandled promise rejections (caused by incorrect / invalid tests) that made it hard to see all the test run output.
This commit is contained in:
@@ -71,7 +71,7 @@ suite('auto OAuth dialog controller tests', () => {
|
||||
|
||||
});
|
||||
|
||||
test('Open auto OAuth when the flyout is already open, return an error', () => {
|
||||
test('Open auto OAuth when the flyout is already open, return an error', (done) => {
|
||||
|
||||
// If: Open auto OAuth dialog first time
|
||||
autoOAuthDialogController.openAutoOAuthDialog(providerId, title, message, userCode, uri);
|
||||
@@ -81,7 +81,8 @@ suite('auto OAuth dialog controller tests', () => {
|
||||
mockErrorMessageService.verify(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.never());
|
||||
|
||||
// If: a oauth flyout is already open
|
||||
autoOAuthDialogController.openAutoOAuthDialog(providerId, title, message, userCode, uri);
|
||||
autoOAuthDialogController.openAutoOAuthDialog(providerId, title, message, userCode, uri)
|
||||
.then(success => done('Failure: Expected error on 2nd dialog open'), error => done());
|
||||
|
||||
// Then: An error dialog should have been opened
|
||||
mockErrorMessageService.verify(x => x.showDialog(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.once());
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
|
||||
export async function assertThrowsAsync(fn, regExp?: string): Promise<void> {
|
||||
export async function assertThrowsAsync(fn, regExp?: any): Promise<void> {
|
||||
let f = () => {
|
||||
// Empty
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ suite('ExtHostAccountManagement', () => {
|
||||
instantiationService.stub(IRPCProtocol, threadService);
|
||||
instantiationService.stub(IAccountManagementService, accountMgmtStub);
|
||||
|
||||
const accountMgmtService = instantiationService.createInstance(MainThreadAccountManagement);
|
||||
const accountMgmtService = instantiationService.createInstance(MainThreadAccountManagement, undefined);
|
||||
threadService.set(SqlMainContext.MainThreadAccountManagement, accountMgmtService);
|
||||
|
||||
mockAccountMetadata = {
|
||||
@@ -356,7 +356,7 @@ suite('ExtHostAccountManagement', () => {
|
||||
|
||||
let mockAccountManagementService = getMockAccountManagementService(mockAccounts);
|
||||
instantiationService.stub(IAccountManagementService, mockAccountManagementService.object);
|
||||
let accountManagementService = instantiationService.createInstance(MainThreadAccountManagement);
|
||||
let accountManagementService = instantiationService.createInstance(MainThreadAccountManagement, undefined);
|
||||
threadService.set(SqlMainContext.MainThreadAccountManagement, accountManagementService);
|
||||
|
||||
// Setup: Create ext host account management with registered account provider
|
||||
@@ -365,18 +365,10 @@ suite('ExtHostAccountManagement', () => {
|
||||
|
||||
extHost.$getAllAccounts()
|
||||
.then((accounts) => {
|
||||
// If: I get security token
|
||||
extHost.$getSecurityToken(mockAccount1)
|
||||
.then((securityToken) => {
|
||||
// Then: The call should have been passed to the account management service
|
||||
mockAccountManagementService.verify(
|
||||
(obj) => obj.getSecurityToken(TypeMoq.It.isAny()),
|
||||
TypeMoq.Times.once()
|
||||
);
|
||||
}
|
||||
);
|
||||
// If: I get security token it will not throw
|
||||
return extHost.$getSecurityToken(mockAccount1);
|
||||
}
|
||||
).then(() => done(), (err) => done(err));
|
||||
).then(() => done(), (err) => done(new Error(err)));
|
||||
});
|
||||
|
||||
test('GetSecurityToken - Account not found', (done) => {
|
||||
@@ -402,7 +394,7 @@ suite('ExtHostAccountManagement', () => {
|
||||
|
||||
let mockAccountManagementService = getMockAccountManagementService(mockAccounts);
|
||||
instantiationService.stub(IAccountManagementService, mockAccountManagementService.object);
|
||||
let accountManagementService = instantiationService.createInstance(MainThreadAccountManagement);
|
||||
let accountManagementService = instantiationService.createInstance(MainThreadAccountManagement, undefined);
|
||||
threadService.set(SqlMainContext.MainThreadAccountManagement, accountManagementService);
|
||||
|
||||
// Setup: Create ext host account management with registered account provider
|
||||
@@ -423,18 +415,16 @@ suite('ExtHostAccountManagement', () => {
|
||||
isStale: false
|
||||
};
|
||||
|
||||
extHost.$getAllAccounts().then((accounts) => {
|
||||
// If: I get security token for mockAccount2
|
||||
// Then: It should throw
|
||||
assert.throws(
|
||||
() => extHost.$getSecurityToken(mockAccount2),
|
||||
(error) => {
|
||||
return error.message === `Account ${mockAccount2.key.accountId} not found.`;
|
||||
}
|
||||
);
|
||||
extHost.$getAllAccounts()
|
||||
.then(accounts => {
|
||||
return extHost.$getSecurityToken(mockAccount2);
|
||||
})
|
||||
.then((noError) => {
|
||||
done(new Error('Expected getSecurityToken to throw'));
|
||||
}, (err) => {
|
||||
// Expected error caught
|
||||
done();
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ suite('ExtHostCredentialManagement', () => {
|
||||
instantiationService.stub(IRPCProtocol, threadService);
|
||||
instantiationService.stub(ICredentialsService, credentialServiceStub);
|
||||
|
||||
const credentialService = instantiationService.createInstance(MainThreadCredentialManagement);
|
||||
const credentialService = instantiationService.createInstance(MainThreadCredentialManagement, undefined);
|
||||
threadService.set(SqlMainContext.MainThreadCredentialManagement, credentialService);
|
||||
});
|
||||
|
||||
|
||||
@@ -6,18 +6,19 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import URI from 'vs/base/common/uri';
|
||||
import URI, { UriComponents } from 'vs/base/common/uri';
|
||||
import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
|
||||
import { ExtHostNotebookShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { MainThreadNotebook } from 'sql/workbench/api/node/mainThreadNotebook';
|
||||
import { NotebookService } from 'sql/services/notebook/notebookServiceImpl';
|
||||
import { INotebookProvider } from 'sql/services/notebook/notebookService';
|
||||
import { INotebookManagerDetails } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { INotebookManagerDetails, INotebookSessionDetails, INotebookKernelDetails, INotebookFutureDetails } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { LocalContentManager } from 'sql/services/notebook/localContentManager';
|
||||
|
||||
|
||||
suite('MainThreadNotebook Tests', () => {
|
||||
|
||||
let mainThreadNotebook: MainThreadNotebook;
|
||||
@@ -26,14 +27,7 @@ suite('MainThreadNotebook Tests', () => {
|
||||
let mockNotebookService: TypeMoq.Mock<NotebookService>;
|
||||
let providerId = 'TestProvider';
|
||||
setup(() => {
|
||||
mockProxy = TypeMoq.Mock.ofInstance(<ExtHostNotebookShape> {
|
||||
$getNotebookManager: (handle, uri) => undefined,
|
||||
$handleNotebookClosed: (uri) => undefined,
|
||||
$getNotebookContents: (handle, uri) => undefined,
|
||||
$save: (handle, uri, notebook) => undefined,
|
||||
$doStartServer: (handle) => undefined,
|
||||
$doStopServer: (handle) => undefined
|
||||
});
|
||||
mockProxy = TypeMoq.Mock.ofType(ExtHostNotebookStub);
|
||||
let extContext = <IExtHostContext>{
|
||||
getProxy: proxyType => mockProxy.object
|
||||
};
|
||||
@@ -85,6 +79,8 @@ suite('MainThreadNotebook Tests', () => {
|
||||
});
|
||||
mainThreadNotebook.$registerNotebookProvider(providerId, 1);
|
||||
|
||||
// Always return empty specs in this test suite
|
||||
mockProxy.setup(p => p.$refreshSpecs(TypeMoq.It.isAnyNumber())).returns(() => Promise.resolve(undefined));
|
||||
});
|
||||
|
||||
test('should return manager with default content manager & undefined server manager if extension host has none', async () => {
|
||||
@@ -120,4 +116,58 @@ suite('MainThreadNotebook Tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
class ExtHostNotebookStub implements ExtHostNotebookShape {
|
||||
$getNotebookManager(providerHandle: number, notebookUri: UriComponents): Thenable<INotebookManagerDetails> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$handleNotebookClosed(notebookUri: UriComponents): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$doStartServer(managerHandle: number): Thenable<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$doStopServer(managerHandle: number): Thenable<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$getNotebookContents(managerHandle: number, notebookUri: UriComponents): Thenable<sqlops.nb.INotebook> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$save(managerHandle: number, notebookUri: UriComponents, notebook: sqlops.nb.INotebook): Thenable<sqlops.nb.INotebook> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$refreshSpecs(managerHandle: number): Thenable<sqlops.nb.IAllKernels> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$startNewSession(managerHandle: number, options: sqlops.nb.ISessionOptions): Thenable<INotebookSessionDetails> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$shutdownSession(managerHandle: number, sessionId: string): Thenable<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$changeKernel(sessionId: number, kernelInfo: sqlops.nb.IKernelSpec): Thenable<INotebookKernelDetails> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$getKernelReadyStatus(kernelId: number): Thenable<sqlops.nb.IInfoReply> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$getKernelSpec(kernelId: number): Thenable<sqlops.nb.IKernelSpec> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$requestComplete(kernelId: number, content: sqlops.nb.ICompleteRequest): Thenable<sqlops.nb.ICompleteReplyMsg> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$requestExecute(kernelId: number, content: sqlops.nb.IExecuteRequest, disposeOnDone?: boolean): Thenable<INotebookFutureDetails> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$interruptKernel(kernelId: number): Thenable<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$sendInputReply(futureId: number, content: sqlops.nb.IInputReply): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
$disposeFuture(futureId: number): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user