mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Fix service dependency startup warning (#14180)
* Fix service dependency startup warning * fix tests
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||||
|
import { TestInstantiationService as VsTestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An extension of the VS TestInstantiationService which allows for stubbing out createInstance calls
|
||||||
|
* as well as services.
|
||||||
|
*/
|
||||||
|
export class TestInstantiationService extends VsTestInstantiationService {
|
||||||
|
|
||||||
|
private _createInstanceStubsMap: Map<any | SyncDescriptor<any>, any> = new Map<any | SyncDescriptor<any>, any>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a stub for a ctor or descriptor which is then returned when createInstance is called
|
||||||
|
* for that ctor or descriptor.
|
||||||
|
* @param ctorOrDescriptor The ctor or descriptor to stub out
|
||||||
|
* @param obj The object to return instead when createInstance is invoked
|
||||||
|
*/
|
||||||
|
public stubCreateInstance(ctorOrDescriptor: any | SyncDescriptor<any>, obj: any): void {
|
||||||
|
this._createInstanceStubsMap.set(ctorOrDescriptor, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
createInstance(ctorOrDescriptor: any | SyncDescriptor<any>, ...rest: any[]): any {
|
||||||
|
if (this._createInstanceStubsMap.has(ctorOrDescriptor)) {
|
||||||
|
return this._createInstanceStubsMap.get(ctorOrDescriptor);
|
||||||
|
}
|
||||||
|
return super.createInstance(ctorOrDescriptor, ...rest);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,8 +77,6 @@ suite('Notebook Editor Model', function (): void {
|
|||||||
testinstantiationService.stub(IStorageService, new TestStorageService());
|
testinstantiationService.stub(IStorageService, new TestStorageService());
|
||||||
testinstantiationService.stub(IProductService, { quality: 'stable' });
|
testinstantiationService.stub(IProductService, { quality: 'stable' });
|
||||||
const queryConnectionService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose,
|
const queryConnectionService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose,
|
||||||
undefined, // connection store
|
|
||||||
undefined, // connection status manager
|
|
||||||
undefined, // connection dialog service
|
undefined, // connection dialog service
|
||||||
testinstantiationService, // instantiation service
|
testinstantiationService, // instantiation service
|
||||||
undefined, // editor service
|
undefined, // editor service
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => {
|
|||||||
let instantiationService = new TestInstantiationService();
|
let instantiationService = new TestInstantiationService();
|
||||||
instantiationService.stub(IStorageService, new TestStorageService());
|
instantiationService.stub(IStorageService, new TestStorageService());
|
||||||
let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict,
|
let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict,
|
||||||
undefined, //connection store
|
|
||||||
undefined, // connectionstatusmanager
|
|
||||||
undefined, // connectiondialog service
|
undefined, // connectiondialog service
|
||||||
instantiationService, // instantiation service
|
instantiationService, // instantiation service
|
||||||
undefined, // editor service
|
undefined, // editor service
|
||||||
|
|||||||
@@ -93,8 +93,6 @@ suite('SQL QueryEditor Tests', () => {
|
|||||||
let testinstantiationService = new TestInstantiationService();
|
let testinstantiationService = new TestInstantiationService();
|
||||||
testinstantiationService.stub(IStorageService, new TestStorageService());
|
testinstantiationService.stub(IStorageService, new TestStorageService());
|
||||||
connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose,
|
connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose,
|
||||||
undefined, // connection store
|
|
||||||
undefined, // connection status manager
|
|
||||||
undefined, // connection dialog service
|
undefined, // connection dialog service
|
||||||
testinstantiationService, // instantiation service
|
testinstantiationService, // instantiation service
|
||||||
undefined, // editor service
|
undefined, // editor service
|
||||||
@@ -267,8 +265,6 @@ suite('SQL QueryEditor Tests', () => {
|
|||||||
let testinstantiationService = new TestInstantiationService();
|
let testinstantiationService = new TestInstantiationService();
|
||||||
testinstantiationService.stub(IStorageService, new TestStorageService());
|
testinstantiationService.stub(IStorageService, new TestStorageService());
|
||||||
connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose,
|
connectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose,
|
||||||
undefined, // connection store
|
|
||||||
undefined, // connection status manager
|
|
||||||
undefined, // connection dialog service
|
undefined, // connection dialog service
|
||||||
testinstantiationService, // instantiation service
|
testinstantiationService, // instantiation service
|
||||||
undefined, // editor service
|
undefined, // editor service
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ export class AccountManagementService implements IAccountManagementService {
|
|||||||
|
|
||||||
// CONSTRUCTOR /////////////////////////////////////////////////////////
|
// CONSTRUCTOR /////////////////////////////////////////////////////////
|
||||||
constructor(
|
constructor(
|
||||||
private _mementoObj: object,
|
|
||||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||||
@IStorageService private _storageService: IStorageService,
|
@IStorageService private _storageService: IStorageService,
|
||||||
@IClipboardService private _clipboardService: IClipboardService,
|
@IClipboardService private _clipboardService: IClipboardService,
|
||||||
@@ -58,12 +57,9 @@ export class AccountManagementService implements IAccountManagementService {
|
|||||||
@ILogService private readonly _logService: ILogService,
|
@ILogService private readonly _logService: ILogService,
|
||||||
@INotificationService private readonly _notificationService: INotificationService
|
@INotificationService private readonly _notificationService: INotificationService
|
||||||
) {
|
) {
|
||||||
// Create the account store
|
this._mementoContext = new Memento(AccountManagementService.ACCOUNT_MEMENTO, this._storageService);
|
||||||
if (!this._mementoObj) {
|
const mementoObj = this._mementoContext.getMemento(StorageScope.GLOBAL);
|
||||||
this._mementoContext = new Memento(AccountManagementService.ACCOUNT_MEMENTO, this._storageService);
|
this._accountStore = this._instantiationService.createInstance(AccountStore, mementoObj);
|
||||||
this._mementoObj = this._mementoContext.getMemento(StorageScope.GLOBAL);
|
|
||||||
}
|
|
||||||
this._accountStore = this._instantiationService.createInstance(AccountStore, this._mementoObj);
|
|
||||||
|
|
||||||
// Setup the event emitters
|
// Setup the event emitters
|
||||||
this._addAccountProviderEmitter = new Emitter<AccountProviderAddedEventParams>();
|
this._addAccountProviderEmitter = new Emitter<AccountProviderAddedEventParams>();
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ suite('Account Management Service Tests:', () => {
|
|||||||
// If: I add an account when the provider doesn't exist
|
// If: I add an account when the provider doesn't exist
|
||||||
// Then: It should not resolve
|
// Then: It should not resolve
|
||||||
return Promise.race([
|
return Promise.race([
|
||||||
new Promise((resolve, reject) => setTimeout(() => resolve(), 100)),
|
new Promise<void>((resolve, reject) => setTimeout(() => resolve(), 100)),
|
||||||
ams.addAccount('doesNotExist').then(() => { throw new Error('Promise resolved when the provider did not exist'); })
|
ams.addAccount('doesNotExist').then(() => { throw new Error('Promise resolved when the provider did not exist'); })
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@@ -283,7 +283,7 @@ suite('Account Management Service Tests:', () => {
|
|||||||
// If: I get accounts when the provider doesn't exist
|
// If: I get accounts when the provider doesn't exist
|
||||||
// Then: It should not resolve
|
// Then: It should not resolve
|
||||||
return Promise.race([
|
return Promise.race([
|
||||||
new Promise((resolve, reject) => setTimeout(() => resolve(), 100)),
|
new Promise<void>((resolve, reject) => setTimeout(() => resolve(), 100)),
|
||||||
ams.getAccountsForProvider('doesNotExist').then(() => { throw new Error('Promise resolved when the provider did not exist'); })
|
ams.getAccountsForProvider('doesNotExist').then(() => { throw new Error('Promise resolved when the provider did not exist'); })
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@@ -529,13 +529,10 @@ function getTestState(): AccountManagementState {
|
|||||||
mockInstantiationService.setup(x => x.createInstance(TypeMoq.It.isValue(AccountStore), TypeMoq.It.isAny()))
|
mockInstantiationService.setup(x => x.createInstance(TypeMoq.It.isValue(AccountStore), TypeMoq.It.isAny()))
|
||||||
.returns(() => mockAccountStore.object);
|
.returns(() => mockAccountStore.object);
|
||||||
|
|
||||||
// Create mock memento
|
|
||||||
let mockMemento = {};
|
|
||||||
|
|
||||||
const testNotificationService = new TestNotificationService();
|
const testNotificationService = new TestNotificationService();
|
||||||
|
|
||||||
// Create the account management service
|
// Create the account management service
|
||||||
let ams = new AccountManagementService(mockMemento, mockInstantiationService.object, new TestStorageService(), undefined!, undefined!, undefined!, testNotificationService);
|
let ams = new AccountManagementService(mockInstantiationService.object, new TestStorageService(), undefined!, undefined!, undefined!, testNotificationService);
|
||||||
|
|
||||||
// Wire up event handlers
|
// Wire up event handlers
|
||||||
let evUpdate = new EventVerifierSingle<UpdateAccountListEventParams>();
|
let evUpdate = new EventVerifierSingle<UpdateAccountListEventParams>();
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
|||||||
import { ILogService } from 'vs/platform/log/common/log';
|
import { ILogService } from 'vs/platform/log/common/log';
|
||||||
import * as interfaces from 'sql/platform/connection/common/interfaces';
|
import * as interfaces from 'sql/platform/connection/common/interfaces';
|
||||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||||
import { Memento } from 'vs/workbench/common/memento';
|
import { Memento, MementoObject } from 'vs/workbench/common/memento';
|
||||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
|
||||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||||
import { entries } from 'sql/base/common/collections';
|
import { entries } from 'sql/base/common/collections';
|
||||||
import { values } from 'vs/base/common/collections';
|
import { values } from 'vs/base/common/collections';
|
||||||
@@ -70,14 +69,15 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
|||||||
private _connectionGlobalStatus = new ConnectionGlobalStatus(this._notificationService);
|
private _connectionGlobalStatus = new ConnectionGlobalStatus(this._notificationService);
|
||||||
|
|
||||||
private _mementoContext: Memento;
|
private _mementoContext: Memento;
|
||||||
private _mementoObj: any;
|
private _mementoObj: MementoObject;
|
||||||
|
private _connectionStore: ConnectionStore;
|
||||||
|
private _connectionStatusManager: ConnectionStatusManager;
|
||||||
|
|
||||||
private static readonly CONNECTION_MEMENTO = 'ConnectionManagement';
|
private static readonly CONNECTION_MEMENTO = 'ConnectionManagement';
|
||||||
private static readonly _azureResources: AzureResource[] =
|
private static readonly _azureResources: AzureResource[] =
|
||||||
[AzureResource.ResourceManagement, AzureResource.Sql, AzureResource.OssRdbms];
|
[AzureResource.ResourceManagement, AzureResource.Sql, AzureResource.OssRdbms];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _connectionStore: ConnectionStore,
|
|
||||||
private _connectionStatusManager: ConnectionStatusManager,
|
|
||||||
@IConnectionDialogService private _connectionDialogService: IConnectionDialogService,
|
@IConnectionDialogService private _connectionDialogService: IConnectionDialogService,
|
||||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||||
@IEditorService private _editorService: IEditorService,
|
@IEditorService private _editorService: IEditorService,
|
||||||
@@ -91,18 +91,12 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
|||||||
@IAccountManagementService private _accountManagementService: IAccountManagementService,
|
@IAccountManagementService private _accountManagementService: IAccountManagementService,
|
||||||
@ILogService private _logService: ILogService,
|
@ILogService private _logService: ILogService,
|
||||||
@IStorageService private _storageService: IStorageService,
|
@IStorageService private _storageService: IStorageService,
|
||||||
@IEnvironmentService private _environmentService: IEnvironmentService,
|
|
||||||
@IExtensionService private readonly extensionService: IExtensionService
|
@IExtensionService private readonly extensionService: IExtensionService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
if (!this._connectionStore) {
|
this._connectionStore = _instantiationService.createInstance(ConnectionStore);
|
||||||
this._connectionStore = _instantiationService.createInstance(ConnectionStore);
|
this._connectionStatusManager = _instantiationService.createInstance(ConnectionStatusManager);
|
||||||
}
|
|
||||||
if (!this._connectionStatusManager) {
|
|
||||||
this._connectionStatusManager = new ConnectionStatusManager(this._capabilitiesService, this._logService, this._environmentService, this._notificationService);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._storageService) {
|
if (this._storageService) {
|
||||||
this._mementoContext = new Memento(ConnectionManagementService.CONNECTION_MEMENTO, this._storageService);
|
this._mementoContext = new Memento(ConnectionManagementService.CONNECTION_MEMENTO, this._storageService);
|
||||||
this._mementoObj = this._mementoContext.getMemento(StorageScope.GLOBAL);
|
this._mementoObj = this._mementoContext.getMemento(StorageScope.GLOBAL);
|
||||||
|
|||||||
@@ -90,8 +90,6 @@ suite('ConnectionDialogService tests', () => {
|
|||||||
let errorMessageService = getMockErrorMessageService();
|
let errorMessageService = getMockErrorMessageService();
|
||||||
let capabilitiesService = new TestCapabilitiesService();
|
let capabilitiesService = new TestCapabilitiesService();
|
||||||
mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict,
|
mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict,
|
||||||
undefined, // connection store
|
|
||||||
undefined, // connection status manager
|
|
||||||
undefined, // connection dialog service
|
undefined, // connection dialog service
|
||||||
testInstantiationService, // instantiation service
|
testInstantiationService, // instantiation service
|
||||||
undefined, // editor service
|
undefined, // editor service
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ suite('ConnectionDialogWidget tests', () => {
|
|||||||
cmInstantiationService.stub(IContextKeyService, new MockContextKeyService());
|
cmInstantiationService.stub(IContextKeyService, new MockContextKeyService());
|
||||||
|
|
||||||
mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict,
|
mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict,
|
||||||
undefined, // connection store
|
|
||||||
undefined, // connection status manager
|
|
||||||
undefined, // connection dialog service
|
undefined, // connection dialog service
|
||||||
cmInstantiationService, // instantiation service
|
cmInstantiationService, // instantiation service
|
||||||
undefined, // editor service
|
undefined, // editor service
|
||||||
|
|||||||
@@ -25,18 +25,22 @@ import * as azdata from 'azdata';
|
|||||||
|
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import * as TypeMoq from 'typemoq';
|
import * as TypeMoq from 'typemoq';
|
||||||
|
import * as sinon from 'sinon';
|
||||||
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||||
import { TestAccountManagementService } from 'sql/platform/accounts/test/common/testAccountManagementService';
|
import { TestAccountManagementService } from 'sql/platform/accounts/test/common/testAccountManagementService';
|
||||||
import { TestEnvironmentService, TestEditorService } from 'vs/workbench/test/browser/workbenchTestServices';
|
import { TestEnvironmentService, TestEditorService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||||
import { NullLogService } from 'vs/platform/log/common/log';
|
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
|
||||||
import { assign } from 'vs/base/common/objects';
|
import { assign } from 'vs/base/common/objects';
|
||||||
import { NullAdsTelemetryService } from 'sql/platform/telemetry/common/adsTelemetryService';
|
import { NullAdsTelemetryService } from 'sql/platform/telemetry/common/adsTelemetryService';
|
||||||
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
|
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||||
import { IQueryEditorConfiguration } from 'sql/platform/query/common/query';
|
import { IQueryEditorConfiguration } from 'sql/platform/query/common/query';
|
||||||
|
import { TestInstantiationService } from 'sql/platform/instantiation/test/common/instantiationServiceMock';
|
||||||
|
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||||
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
|
|
||||||
suite('SQL ConnectionManagementService tests', () => {
|
suite('SQL ConnectionManagementService tests', () => {
|
||||||
|
|
||||||
@@ -156,11 +160,16 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function createConnectionManagementService(): ConnectionManagementService {
|
function createConnectionManagementService(): ConnectionManagementService {
|
||||||
|
const testInstantiationService = new TestInstantiationService();
|
||||||
|
const testLogService = new NullLogService();
|
||||||
|
testInstantiationService.stub(IStorageService, new TestStorageService());
|
||||||
|
testInstantiationService.stub(ICapabilitiesService, capabilitiesService);
|
||||||
|
testInstantiationService.stub(ILogService, testLogService);
|
||||||
|
testInstantiationService.stubCreateInstance(ConnectionStore, connectionStore.object);
|
||||||
|
|
||||||
let connectionManagementService = new ConnectionManagementService(
|
let connectionManagementService = new ConnectionManagementService(
|
||||||
connectionStore.object,
|
|
||||||
undefined,
|
|
||||||
connectionDialogService.object,
|
connectionDialogService.object,
|
||||||
undefined, // IInstantiationService
|
testInstantiationService,
|
||||||
workbenchEditorService.object,
|
workbenchEditorService.object,
|
||||||
new NullAdsTelemetryService(), // ITelemetryService
|
new NullAdsTelemetryService(), // ITelemetryService
|
||||||
workspaceConfigurationServiceMock.object,
|
workspaceConfigurationServiceMock.object,
|
||||||
@@ -170,9 +179,8 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
resourceProviderStubMock.object,
|
resourceProviderStubMock.object,
|
||||||
undefined, // IAngularEventingService
|
undefined, // IAngularEventingService
|
||||||
accountManagementService.object,
|
accountManagementService.object,
|
||||||
new NullLogService(), // ILogService
|
testLogService, // ILogService
|
||||||
undefined, // IStorageService
|
undefined, // IStorageService
|
||||||
TestEnvironmentService,
|
|
||||||
getBasicExtensionService()
|
getBasicExtensionService()
|
||||||
);
|
);
|
||||||
return connectionManagementService;
|
return connectionManagementService;
|
||||||
@@ -1556,7 +1564,10 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
profile.password = test_password;
|
profile.password = test_password;
|
||||||
return { profile: profile, savedCred: true };
|
return { profile: profile, savedCred: true };
|
||||||
});
|
});
|
||||||
const connectionManagementService = new ConnectionManagementService(connectionStoreMock.object, undefined, undefined, undefined, undefined, undefined, undefined, new TestCapabilitiesService(), undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, getBasicExtensionService());
|
const testInstantiationService = new TestInstantiationService();
|
||||||
|
testInstantiationService.stub(IStorageService, new TestStorageService());
|
||||||
|
testInstantiationService.stubCreateInstance(ConnectionStore, connectionStoreMock.object);
|
||||||
|
const connectionManagementService = new ConnectionManagementService(undefined, testInstantiationService, undefined, undefined, undefined, new TestCapabilitiesService(), undefined, undefined, undefined, undefined, undefined, undefined, undefined, getBasicExtensionService());
|
||||||
assert.equal(profile.password, '', 'Profile should not have password initially');
|
assert.equal(profile.password, '', 'Profile should not have password initially');
|
||||||
assert.equal(profile.options['password'], '', 'Profile options should not have password initially');
|
assert.equal(profile.options['password'], '', 'Profile options should not have password initially');
|
||||||
// Check for invalid profile id
|
// Check for invalid profile id
|
||||||
@@ -1582,7 +1593,11 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
profile.password = test_password;
|
profile.password = test_password;
|
||||||
return { profile: profile, savedCred: true };
|
return { profile: profile, savedCred: true };
|
||||||
});
|
});
|
||||||
const connectionManagementService = new ConnectionManagementService(connectionStoreMock.object, undefined, undefined, undefined, undefined, undefined, undefined, new TestCapabilitiesService(), undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, getBasicExtensionService());
|
const testInstantiationService = new TestInstantiationService();
|
||||||
|
testInstantiationService.stub(IStorageService, new TestStorageService());
|
||||||
|
testInstantiationService.stubCreateInstance(ConnectionStore, connectionStoreMock.object);
|
||||||
|
|
||||||
|
const connectionManagementService = new ConnectionManagementService(undefined, testInstantiationService, undefined, undefined, undefined, new TestCapabilitiesService(), undefined, undefined, undefined, undefined, undefined, undefined, undefined, getBasicExtensionService());
|
||||||
assert.equal(profile.password, '', 'Profile should not have password initially');
|
assert.equal(profile.password, '', 'Profile should not have password initially');
|
||||||
assert.equal(profile.options['password'], '', 'Profile options should not have password initially');
|
assert.equal(profile.options['password'], '', 'Profile options should not have password initially');
|
||||||
let credentials = await connectionManagementService.getConnectionCredentials(profile.id);
|
let credentials = await connectionManagementService.getConnectionCredentials(profile.id);
|
||||||
@@ -1734,7 +1749,6 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
test('getConnections test', () => {
|
test('getConnections test', () => {
|
||||||
const connectionStatusManagerMock = TypeMoq.Mock.ofType(ConnectionStatusManager, TypeMoq.MockBehavior.Loose);
|
const connectionStatusManagerMock = TypeMoq.Mock.ofType(ConnectionStatusManager, TypeMoq.MockBehavior.Loose);
|
||||||
const connectionStoreMock = TypeMoq.Mock.ofType(ConnectionStore, TypeMoq.MockBehavior.Loose, new TestStorageService());
|
const connectionStoreMock = TypeMoq.Mock.ofType(ConnectionStore, TypeMoq.MockBehavior.Loose, new TestStorageService());
|
||||||
|
|
||||||
connectionStatusManagerMock.setup(x => x.getActiveConnectionProfiles(undefined)).returns(() => {
|
connectionStatusManagerMock.setup(x => x.getActiveConnectionProfiles(undefined)).returns(() => {
|
||||||
return [createConnectionProfile('1'), createConnectionProfile('2')];
|
return [createConnectionProfile('1'), createConnectionProfile('2')];
|
||||||
});
|
});
|
||||||
@@ -1750,7 +1764,13 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
connectionStoreMock.setup(x => x.getConnectionProfileGroups(TypeMoq.It.isAny(), undefined)).returns(() => {
|
connectionStoreMock.setup(x => x.getConnectionProfileGroups(TypeMoq.It.isAny(), undefined)).returns(() => {
|
||||||
return [group1];
|
return [group1];
|
||||||
});
|
});
|
||||||
const connectionManagementService = new ConnectionManagementService(connectionStoreMock.object, connectionStatusManagerMock.object, undefined, undefined, undefined, undefined, undefined, new TestCapabilitiesService(), undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, getBasicExtensionService());
|
|
||||||
|
const testInstantiationService = new TestInstantiationService();
|
||||||
|
const createInstanceStub = sinon.stub(testInstantiationService, 'createInstance');
|
||||||
|
createInstanceStub.withArgs(ConnectionStore).returns(connectionStoreMock.object);
|
||||||
|
createInstanceStub.withArgs(ConnectionStatusManager).returns(connectionStatusManagerMock.object);
|
||||||
|
|
||||||
|
const connectionManagementService = new ConnectionManagementService(undefined, testInstantiationService, undefined, undefined, undefined, new TestCapabilitiesService(), undefined, undefined, undefined, undefined, undefined, undefined, undefined, getBasicExtensionService());
|
||||||
|
|
||||||
// dupe connections have been seeded the numbers below already reflected the de-duped results
|
// dupe connections have been seeded the numbers below already reflected the de-duped results
|
||||||
|
|
||||||
@@ -1774,20 +1794,21 @@ suite('SQL ConnectionManagementService tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('isRecent should evaluate whether a profile was recently connected or not', () => {
|
test('isRecent should evaluate whether a profile was recently connected or not', () => {
|
||||||
const connectionStatusManagerMock = TypeMoq.Mock.ofType(ConnectionStatusManager, TypeMoq.MockBehavior.Loose);
|
|
||||||
const connectionStoreMock = TypeMoq.Mock.ofType(ConnectionStore, TypeMoq.MockBehavior.Loose, new TestStorageService());
|
const connectionStoreMock = TypeMoq.Mock.ofType(ConnectionStore, TypeMoq.MockBehavior.Loose, new TestStorageService());
|
||||||
|
const testInstantiationService = new TestInstantiationService();
|
||||||
|
testInstantiationService.stub(IStorageService, new TestStorageService());
|
||||||
|
sinon.stub(testInstantiationService, 'createInstance').withArgs(ConnectionStore).returns(connectionStoreMock.object);
|
||||||
connectionStoreMock.setup(x => x.getRecentlyUsedConnections()).returns(() => {
|
connectionStoreMock.setup(x => x.getRecentlyUsedConnections()).returns(() => {
|
||||||
return [createConnectionProfile('1')];
|
return [createConnectionProfile('1')];
|
||||||
});
|
});
|
||||||
let profile1 = createConnectionProfile('1');
|
let profile1 = createConnectionProfile('1');
|
||||||
let profile2 = createConnectionProfile('2');
|
let profile2 = createConnectionProfile('2');
|
||||||
const connectionManagementService = new ConnectionManagementService(connectionStoreMock.object, connectionStatusManagerMock.object, undefined, undefined, undefined, undefined, undefined, new TestCapabilitiesService(), undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, getBasicExtensionService());
|
const connectionManagementService = new ConnectionManagementService(undefined, testInstantiationService, undefined, undefined, undefined, new TestCapabilitiesService(), undefined, undefined, undefined, undefined, undefined, undefined, undefined, getBasicExtensionService());
|
||||||
assert(connectionManagementService.isRecent(profile1));
|
assert(connectionManagementService.isRecent(profile1));
|
||||||
assert(!connectionManagementService.isRecent(profile2));
|
assert(!connectionManagementService.isRecent(profile2));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clearRecentConnection and ConnectionsList should call connectionStore functions', () => {
|
test('clearRecentConnection and ConnectionsList should call connectionStore functions', () => {
|
||||||
const connectionStatusManagerMock = TypeMoq.Mock.ofType(ConnectionStatusManager, TypeMoq.MockBehavior.Loose);
|
|
||||||
const connectionStoreMock = TypeMoq.Mock.ofType(ConnectionStore, TypeMoq.MockBehavior.Loose, new TestStorageService());
|
const connectionStoreMock = TypeMoq.Mock.ofType(ConnectionStore, TypeMoq.MockBehavior.Loose, new TestStorageService());
|
||||||
let called = false;
|
let called = false;
|
||||||
connectionStoreMock.setup(x => x.clearRecentlyUsed()).returns(() => {
|
connectionStoreMock.setup(x => x.clearRecentlyUsed()).returns(() => {
|
||||||
@@ -1796,8 +1817,11 @@ test('clearRecentConnection and ConnectionsList should call connectionStore func
|
|||||||
connectionStoreMock.setup(x => x.removeRecentConnection(TypeMoq.It.isAny())).returns(() => {
|
connectionStoreMock.setup(x => x.removeRecentConnection(TypeMoq.It.isAny())).returns(() => {
|
||||||
called = true;
|
called = true;
|
||||||
});
|
});
|
||||||
|
const testInstantiationService = new TestInstantiationService();
|
||||||
|
testInstantiationService.stub(IStorageService, new TestStorageService());
|
||||||
|
sinon.stub(testInstantiationService, 'createInstance').withArgs(ConnectionStore).returns(connectionStoreMock.object);
|
||||||
let profile1 = createConnectionProfile('1');
|
let profile1 = createConnectionProfile('1');
|
||||||
const connectionManagementService = new ConnectionManagementService(connectionStoreMock.object, connectionStatusManagerMock.object, undefined, undefined, undefined, undefined, undefined, new TestCapabilitiesService(), undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, getBasicExtensionService());
|
const connectionManagementService = new ConnectionManagementService(undefined, testInstantiationService, undefined, undefined, undefined, new TestCapabilitiesService(), undefined, undefined, undefined, undefined, undefined, undefined, undefined, getBasicExtensionService());
|
||||||
connectionManagementService.clearRecentConnection(profile1);
|
connectionManagementService.clearRecentConnection(profile1);
|
||||||
assert(called);
|
assert(called);
|
||||||
called = false;
|
called = false;
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ suite('Insights Dialog Controller Tests', () => {
|
|||||||
let testinstantiationService = new TestInstantiationService();
|
let testinstantiationService = new TestInstantiationService();
|
||||||
testinstantiationService.stub(IStorageService, new TestStorageService());
|
testinstantiationService.stub(IStorageService, new TestStorageService());
|
||||||
let connMoq = Mock.ofType(ConnectionManagementService, MockBehavior.Strict,
|
let connMoq = Mock.ofType(ConnectionManagementService, MockBehavior.Strict,
|
||||||
undefined, // connection store
|
|
||||||
undefined, // connection status manager
|
|
||||||
undefined, // connection dialog service
|
undefined, // connection dialog service
|
||||||
testinstantiationService, // instantiation service
|
testinstantiationService, // instantiation service
|
||||||
undefined, // editor service
|
undefined, // editor service
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ suite('AsyncServerTreeDragAndDrop', () => {
|
|||||||
let instantiationService = new TestInstantiationService();
|
let instantiationService = new TestInstantiationService();
|
||||||
instantiationService.stub(IStorageService, new TestStorageService());
|
instantiationService.stub(IStorageService, new TestStorageService());
|
||||||
let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict,
|
let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict,
|
||||||
undefined, //connection store
|
|
||||||
undefined, // connectionstatusmanager
|
|
||||||
undefined, // connectiondialog service
|
undefined, // connectiondialog service
|
||||||
instantiationService, // instantiation service
|
instantiationService, // instantiation service
|
||||||
undefined, // editor service
|
undefined, // editor service
|
||||||
|
|||||||
@@ -59,8 +59,6 @@ suite('SQL Drag And Drop Controller tests', () => {
|
|||||||
let instantiationService = new TestInstantiationService();
|
let instantiationService = new TestInstantiationService();
|
||||||
instantiationService.stub(IStorageService, new TestStorageService());
|
instantiationService.stub(IStorageService, new TestStorageService());
|
||||||
let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict,
|
let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict,
|
||||||
undefined, //connection store
|
|
||||||
undefined, // connectionstatusmanager
|
|
||||||
undefined, // connectiondialog service
|
undefined, // connectiondialog service
|
||||||
instantiationService, // instantiation service
|
instantiationService, // instantiation service
|
||||||
undefined, // editor service
|
undefined, // editor service
|
||||||
|
|||||||
Reference in New Issue
Block a user