mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-04-01 17:40:30 -04:00
Feature/ext connection dialog (#2201)
* Connection Dialog API for extensions
This commit is contained in:
@@ -23,7 +23,7 @@ suite('ConnectionDialogService tests', () => {
|
||||
setup(() => {
|
||||
let errorMessageService = getMockErrorMessageService();
|
||||
connectionDialogService = new ConnectionDialogService(undefined, undefined, undefined, errorMessageService.object,
|
||||
undefined, undefined, undefined, undefined);
|
||||
undefined, undefined, undefined);
|
||||
mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict, {}, {});
|
||||
(connectionDialogService as any)._connectionManagementService = mockConnectionManagementService.object;
|
||||
mockConnectionDialog = TypeMoq.Mock.ofType(ConnectionDialogWidget, TypeMoq.MockBehavior.Strict,
|
||||
@@ -34,6 +34,7 @@ suite('ConnectionDialogService tests', () => {
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
new ContextKeyServiceStub()
|
||||
);
|
||||
mockConnectionDialog.setup(c => c.resetConnection());
|
||||
|
||||
@@ -108,7 +108,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
c => c.serverName === connectionProfileWithEmptyUnsavedPassword.serverName))).returns(
|
||||
() => Promise.resolve({ profile: connectionProfileWithEmptyUnsavedPassword, savedCred: false }));
|
||||
connectionStore.setup(x => x.isPasswordRequired(TypeMoq.It.isAny())).returns(() => true);
|
||||
connectionStore.setup(x => x.getConnectionProfileGroups()).returns(() => [root]);
|
||||
connectionStore.setup(x => x.getConnectionProfileGroups(false, undefined)).returns(() => [root]);
|
||||
|
||||
mssqlConnectionProvider.setup(x => x.connect(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => undefined);
|
||||
|
||||
@@ -172,7 +172,7 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
connectionDialogService.verify(x => x.showDialog(
|
||||
TypeMoq.It.isAny(),
|
||||
TypeMoq.It.is<INewConnectionParams>(p => p.connectionType === connectionType && (uri === undefined || p.input.uri === uri)),
|
||||
TypeMoq.It.is<IConnectionProfile>(c => c.serverName === connectionProfile.serverName),
|
||||
TypeMoq.It.is<IConnectionProfile>(c => c !== undefined && c.serverName === connectionProfile.serverName),
|
||||
connectionResult ? TypeMoq.It.is<IConnectionResult>(r => r.errorMessage === connectionResult.errorMessage && r.callStack === connectionResult.callStack) : undefined),
|
||||
didShow ? TypeMoq.Times.once() : TypeMoq.Times.never());
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/com
|
||||
suite('SQL ConnectionStore tests', () => {
|
||||
let defaultNamedProfile: IConnectionProfile;
|
||||
let defaultUnnamedProfile: IConnectionProfile;
|
||||
let profileForProvider2: IConnectionProfile;
|
||||
let context: TypeMoq.Mock<Memento>;
|
||||
let credentialStore: TypeMoq.Mock<CredentialsService>;
|
||||
let connectionConfig: TypeMoq.Mock<ConnectionConfig>;
|
||||
@@ -35,6 +36,7 @@ suite('SQL ConnectionStore tests', () => {
|
||||
let mementoArray: any = [];
|
||||
let maxRecent = 5;
|
||||
let msSQLCapabilities: ConnectionProviderProperties;
|
||||
let provider2Capabilities: ConnectionProviderProperties;
|
||||
let defaultNamedConnectionProfile: ConnectionProfile;
|
||||
|
||||
setup(() => {
|
||||
@@ -72,6 +74,23 @@ suite('SQL ConnectionStore tests', () => {
|
||||
id: undefined
|
||||
});
|
||||
|
||||
profileForProvider2 = Object.assign({}, {
|
||||
serverName: 'unnamedServer',
|
||||
databaseName: undefined,
|
||||
authenticationType: 'SqlLogin',
|
||||
userName: 'aUser',
|
||||
password: 'asdf!@#$',
|
||||
savePassword: true,
|
||||
groupId: '',
|
||||
groupFullName: '',
|
||||
getOptionsKey: undefined,
|
||||
matches: undefined,
|
||||
providerName: 'MSSQL',
|
||||
options: {},
|
||||
saveProfile: true,
|
||||
id: undefined
|
||||
});
|
||||
|
||||
let momento = new Memento('ConnectionManagement');
|
||||
context = TypeMoq.Mock.ofInstance(momento);
|
||||
context.setup(x => x.getMemento(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => mementoArray);
|
||||
@@ -164,7 +183,14 @@ suite('SQL ConnectionStore tests', () => {
|
||||
displayName: 'MSSQL',
|
||||
connectionOptions: connectionProvider
|
||||
};
|
||||
|
||||
provider2Capabilities = {
|
||||
providerId: 'MSSQL',
|
||||
displayName: 'MSSQL',
|
||||
connectionOptions: connectionProvider
|
||||
};
|
||||
capabilitiesService.capabilities['MSSQL'] = { connection: msSQLCapabilities };
|
||||
capabilitiesService.capabilities['Provider2'] = { connection: provider2Capabilities };
|
||||
let groups: IConnectionProfileGroup[] = [
|
||||
{
|
||||
id: 'root',
|
||||
@@ -226,6 +252,14 @@ suite('SQL ConnectionStore tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('getRecentlyUsedConnections should return connection for given provider', () => {
|
||||
let connectionStore = new ConnectionStore(storageServiceMock.object, context.object, undefined, workspaceConfigurationServiceMock.object,
|
||||
credentialStore.object, capabilitiesService, connectionConfig.object);
|
||||
let connections = connectionStore.getRecentlyUsedConnections(['Provider2']);
|
||||
assert.notEqual(connections, undefined);
|
||||
assert.equal(connections.every(c => c.providerName === 'Provider2'), true);
|
||||
});
|
||||
|
||||
test('addActiveConnection should add same connection exactly once', (done) => {
|
||||
// setup memento for MRU to return a list we have access to
|
||||
credentialStore.setup(x => x.saveCredential(TypeMoq.It.isAny(), TypeMoq.It.isAny()))
|
||||
|
||||
Reference in New Issue
Block a user