Remove typings and replace missing methods with vscodes (#8217)

* remove typings and replace missing methods with vscodes

* fix strict-null-checks

* fix tests
This commit is contained in:
Anthony Dresser
2019-11-05 13:03:20 -08:00
committed by GitHub
parent 4645a8ba6b
commit 22a427f934
184 changed files with 634 additions and 43388 deletions

View File

@@ -12,6 +12,7 @@ import * as Utils from 'sql/platform/connection/common/utils';
import { generateUuid } from 'vs/base/common/uuid';
import * as nls from 'vs/nls';
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { find, firstIndex } from 'vs/base/common/arrays';
const GROUPS_CONFIG_KEY = 'datasource.connectionGroups';
const CONNECTIONS_CONFIG_KEY = 'datasource.connections';
@@ -43,7 +44,7 @@ export class ConnectionConfig {
if (user) {
if (workspace) {
user = user.filter(x => workspace.find(f => this.isSameGroupName(f, x)) === undefined);
user = user.filter(x => find(workspace, f => this.isSameGroupName(f, x)) === undefined);
allGroups = allGroups.concat(workspace);
}
allGroups = allGroups.concat(user);
@@ -71,12 +72,12 @@ export class ConnectionConfig {
let newProfile = ConnectionProfile.convertToProfileStore(this._capabilitiesService, connectionProfile);
// Remove the profile if already set
let sameProfileInList = profiles.find(value => {
let sameProfileInList = find(profiles, value => {
let providerConnectionProfile = ConnectionProfile.createFromStoredProfile(value, this._capabilitiesService);
return providerConnectionProfile.matches(connectionProfile);
});
if (sameProfileInList) {
let profileIndex = profiles.findIndex(value => value === sameProfileInList);
let profileIndex = firstIndex(profiles, value => value === sameProfileInList);
newProfile.id = sameProfileInList.id;
connectionProfile.id = sameProfileInList.id;
profiles[profileIndex] = newProfile;
@@ -123,7 +124,7 @@ export class ConnectionConfig {
return Promise.resolve(profileGroup.id);
} else {
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).user;
let sameNameGroup = groups ? groups.find(group => group.name === profileGroup.name) : undefined;
let sameNameGroup = groups ? find(groups, group => group.name === profileGroup.name) : undefined;
if (sameNameGroup) {
let errMessage: string = nls.localize('invalidServerName', "A server group with the same name already exists.");
return Promise.reject(errMessage);
@@ -276,7 +277,7 @@ export class ConnectionConfig {
*/
public canChangeConnectionConfig(profile: ConnectionProfile, newGroupID: string): boolean {
let profiles = this.getConnections(true);
let existingProfile = profiles.find(p => p.getConnectionInfoId() === profile.getConnectionInfoId()
let existingProfile = find(profiles, p => p.getConnectionInfoId() === profile.getConnectionInfoId()
&& p.groupId === newGroupID);
return existingProfile === undefined;
}
@@ -328,7 +329,7 @@ export class ConnectionConfig {
public editGroup(source: ConnectionProfileGroup): Promise<void> {
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).user;
let sameNameGroup = groups ? groups.find(group => group.name === source.name && group.id !== source.id) : undefined;
let sameNameGroup = groups ? find(groups, group => group.name === source.name && group.id !== source.id) : undefined;
if (sameNameGroup) {
let errMessage: string = nls.localize('invalidServerName', "A server group with the same name already exists.");
return Promise.reject(errMessage);
@@ -369,7 +370,7 @@ export class ConnectionConfig {
color: color,
description: description
} as IConnectionProfileGroup;
let found = groupTree.find(group => this.isSameGroupName(group, newGroup));
let found = find(groupTree, group => this.isSameGroupName(group, newGroup));
if (found) {
if (index === groupNames.length - 1) {
newGroupId = found.id;

View File

@@ -14,6 +14,7 @@ import { isString } from 'vs/base/common/types';
import { deepClone } from 'vs/base/common/objects';
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
import * as Constants from 'sql/platform/connection/common/constants';
import { find } from 'vs/base/common/arrays';
// Concrete implementation of the IConnectionProfile interface
@@ -46,7 +47,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
let capabilities = this.capabilitiesService.getCapabilities(model.providerName);
if (capabilities && capabilities.connection && capabilities.connection.connectionOptions) {
const options = capabilities.connection.connectionOptions;
let appNameOption = options.find(option => option.specialValueType === ConnectionOptionSpecialType.appName);
let appNameOption = find(options, option => option.specialValueType === ConnectionOptionSpecialType.appName);
if (appNameOption) {
let appNameKey = appNameOption.name;
this.options[appNameKey] = Constants.applicationName;

View File

@@ -6,6 +6,8 @@
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { Disposable } from 'vs/base/common/lifecycle';
import { isUndefinedOrNull } from 'vs/base/common/types';
import { assign } from 'vs/base/common/objects';
import { find } from 'vs/base/common/arrays';
export interface IConnectionProfileGroup {
id: string;
@@ -47,7 +49,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
});
}
return Object.assign({}, { name: this.name, id: this.id, parentId: this.parentId, children: subgroups, color: this.color, description: this.description });
return assign({}, { name: this.name, id: this.id, parentId: this.parentId, children: subgroups, color: this.color, description: this.description });
}
public get groupName(): string {
@@ -85,7 +87,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
*/
public get hasValidConnections(): boolean {
if (this.connections) {
let invalidConnections = this.connections.find(c => !c.isConnectionOptionsValid);
let invalidConnections = find(this.connections, c => !c.isConnectionOptionsValid);
if (invalidConnections !== undefined) {
return false;
} else {

View File

@@ -14,6 +14,9 @@ import { join } from 'vs/base/common/path';
import * as Utils from 'sql/platform/connection/common/utils';
import * as azdata from 'azdata';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { startsWith } from 'vs/base/common/strings';
import { values } from 'vs/base/common/collections';
import { firstIndex, find } from 'vs/base/common/arrays';
export class ConnectionStatusManager {
@@ -35,8 +38,8 @@ export class ConnectionStatusManager {
}
}
public findConnectionByProfileId(profileId: string): ConnectionManagementInfo {
return Object.values(this._connections).find((connection: ConnectionManagementInfo) => connection.connectionProfile.id === profileId);
public findConnectionByProfileId(profileId: string): ConnectionManagementInfo | undefined {
return find(values(this._connections), connection => connection.connectionProfile.id === profileId);
}
public findConnectionProfile(connectionProfile: IConnectionProfile): ConnectionManagementInfo | undefined {
@@ -190,7 +193,7 @@ export class ConnectionStatusManager {
}
private isSharedSession(fileUri: string): boolean {
return !!(fileUri && fileUri.startsWith('vsls:'));
return !!(fileUri && startsWith(fileUri, 'vsls:'));
}
public isConnected(id: string): boolean {
@@ -205,7 +208,7 @@ export class ConnectionStatusManager {
}
public isDefaultTypeUri(uri: string): boolean {
return !!(uri && uri.startsWith(Utils.uriPrefixes.default));
return !!(uri && startsWith(uri, Utils.uriPrefixes.default));
}
public getProviderIdFromUri(ownerUri: string): string {
@@ -225,12 +228,12 @@ export class ConnectionStatusManager {
* Get a list of the active connection profiles managed by the status manager
*/
public getActiveConnectionProfiles(providers?: string[]): ConnectionProfile[] {
let profiles = Object.values(this._connections).map((connectionInfo: ConnectionManagementInfo) => connectionInfo.connectionProfile);
let profiles = values(this._connections).map((connectionInfo: ConnectionManagementInfo) => connectionInfo.connectionProfile);
// Remove duplicate profiles that may be listed multiple times under different URIs by filtering for profiles that don't have the same ID as an earlier profile in the list
profiles = profiles.filter((profile, index) => profiles.findIndex(otherProfile => otherProfile.id === profile.id) === index);
profiles = profiles.filter((profile, index) => firstIndex(profiles, otherProfile => otherProfile.id === profile.id) === index);
if (providers) {
profiles = profiles.filter(f => providers.includes(f.providerName));
profiles = profiles.filter(f => find(providers, x => x === f.providerName));
}
return profiles;
}

View File

@@ -13,6 +13,7 @@ import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { ICredentialsService } from 'sql/platform/credentials/common/credentialsService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { find } from 'vs/base/common/arrays';
const MAX_CONNECTIONS_DEFAULT = 25;
@@ -150,7 +151,7 @@ export class ConnectionStore {
public getRecentlyUsedConnections(providers?: string[]): ConnectionProfile[] {
let mru = this.mru.slice();
if (providers && providers.length > 0) {
mru = mru.filter(c => providers.includes(c.providerName));
mru = mru.filter(c => find(providers, x => x === c.providerName));
}
return this.convertConfigValuesToConnectionProfiles(mru);
}
@@ -277,7 +278,7 @@ export class ConnectionStore {
if (!withoutConnections) {
profilesInConfiguration = this.connectionConfig.getConnections(true);
if (providers && providers.length > 0) {
profilesInConfiguration = profilesInConfiguration.filter(x => providers.includes(x.providerName));
profilesInConfiguration = profilesInConfiguration.filter(x => find(providers, p => p === x.providerName));
}
}
const groups = this.connectionConfig.getAllGroups();
@@ -313,9 +314,9 @@ export class ConnectionStore {
return result;
}
public getGroupFromId(groupId: string): IConnectionProfileGroup {
public getGroupFromId(groupId: string): IConnectionProfileGroup | undefined {
const groups = this.connectionConfig.getAllGroups();
return groups.find(group => group.id === groupId);
return find(groups, group => group.id === groupId);
}
private getMaxRecentConnectionsCount(): number {

View File

@@ -10,6 +10,8 @@ import * as azdata from 'azdata';
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
import * as Constants from 'sql/platform/connection/common/constants';
import { ICapabilitiesService, ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
import { assign } from 'vs/base/common/objects';
import { find } from 'vs/base/common/arrays';
type SettableProperty = 'serverName' | 'authenticationType' | 'databaseName' | 'password' | 'connectionName' | 'userName';
@@ -94,7 +96,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
public clone(): ProviderConnectionInfo {
let instance = new ProviderConnectionInfo(this.capabilitiesService, this.providerName);
instance.options = Object.assign({}, this.options);
instance.options = assign({}, this.options);
return instance;
}
@@ -196,9 +198,9 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
return false;
}
let optionMetadata = this._serverCapabilities.connectionOptions.find(
option => option.specialValueType === ConnectionOptionSpecialType.password);
let isPasswordRequired: boolean = optionMetadata.isRequired;
let optionMetadata = find(this._serverCapabilities.connectionOptions,
option => option.specialValueType === ConnectionOptionSpecialType.password)!; // i guess we are going to assume there is a password field
let isPasswordRequired = optionMetadata.isRequired;
if (this.providerName === Constants.mssqlProviderName) {
isPasswordRequired = this.authenticationType === ProviderConnectionInfo.SqlAuthentication && optionMetadata.isRequired;
}
@@ -267,7 +269,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
public getSpecialTypeOptionName(type: string): string | undefined {
if (this._serverCapabilities) {
let optionMetadata = this._serverCapabilities.connectionOptions.find(o => o.specialValueType === type);
let optionMetadata = find(this._serverCapabilities.connectionOptions, o => o.specialValueType === type);
return !!optionMetadata ? optionMetadata.name : undefined;
} else {
return type.toString();
@@ -282,7 +284,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
}
public get authenticationTypeDisplayName(): string {
let optionMetadata = this._serverCapabilities.connectionOptions.find(o => o.specialValueType === ConnectionOptionSpecialType.authType);
let optionMetadata = find(this._serverCapabilities.connectionOptions, o => o.specialValueType === ConnectionOptionSpecialType.authType);
let authType = this.authenticationType;
let displayName: string = authType;

View File

@@ -17,6 +17,7 @@ import * as TypeMoq from 'typemoq';
import { Emitter } from 'vs/base/common/event';
import { deepClone, deepFreeze } from 'vs/base/common/objects';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { find } from 'vs/base/common/arrays';
suite('ConnectionConfig', () => {
let capabilitiesService: TypeMoq.Mock<ICapabilitiesService>;
@@ -210,7 +211,7 @@ suite('ConnectionConfig', () => {
}
for (let group of groups1) {
let g2 = groups2.find(g => g.name === group.name);
let g2 = find(groups2, g => g.name === group.name);
// if we couldn't find the group it means they must not be equal
if (!g2) {
return false;
@@ -373,12 +374,12 @@ suite('ConnectionConfig', () => {
let allConnections = config.getConnections(false);
assert.equal(allConnections.length, testConnections.length);
allConnections.forEach(connection => {
let userConnection = testConnections.find(u => u.options['serverName'] === connection.serverName);
let userConnection = find(testConnections, u => u.options['serverName'] === connection.serverName);
if (userConnection !== undefined) {
assert.notEqual(connection.id, connection.getOptionsKey());
assert.ok(!!connection.id);
} else {
let workspaceConnection = workspaceConnections.find(u => u.options['serverName'] === connection.serverName);
let workspaceConnection = find(workspaceConnections, u => u.options['serverName'] === connection.serverName);
assert.notEqual(connection.id, connection.getOptionsKey());
assert.equal(workspaceConnection.id, connection.id);
}
@@ -394,7 +395,7 @@ suite('ConnectionConfig', () => {
let result: ISaveGroupResult = config.saveGroup(groups, newGroups, color, newGroups);
assert.ok(!!result);
assert.equal(result.groups.length, testGroups.length + 2, 'The result groups length is invalid');
let newGroup = result.groups.find(g => g.name === 'new-group2');
let newGroup = find(result.groups, g => g.name === 'new-group2');
assert.equal(result.newGroupId, newGroup.id, 'The groups id is invalid');
});
@@ -407,7 +408,7 @@ suite('ConnectionConfig', () => {
let result: ISaveGroupResult = config.saveGroup(groups, newGroups, color, newGroups);
assert.ok(!!result);
assert.equal(result.groups.length, testGroups.length + 1, 'The result groups length is invalid');
let newGroup = result.groups.find(g => g.name === 'g2-5');
let newGroup = find(result.groups, g => g.name === 'g2-5');
assert.equal(result.newGroupId, newGroup.id, 'The groups id is invalid');
});
@@ -420,7 +421,7 @@ suite('ConnectionConfig', () => {
let result: ISaveGroupResult = config.saveGroup(groups, newGroups, color, newGroups);
assert.ok(!!result);
assert.equal(result.groups.length, testGroups.length, 'The result groups length is invalid');
let newGroup = result.groups.find(g => g.name === 'g2-1');
let newGroup = find(result.groups, g => g.name === 'g2-1');
assert.equal(result.newGroupId, newGroup.id, 'The groups id is invalid');
});
@@ -530,7 +531,7 @@ suite('ConnectionConfig', () => {
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
assert.equal(editedGroups.length, testGroups.length);
let editedGroup = editedGroups.find(group => group.id === 'g2');
let editedGroup = find(editedGroups, group => group.id === 'g2');
assert.ok(!!editedGroup);
assert.equal(editedGroup.name, 'g-renamed');
});
@@ -547,7 +548,7 @@ suite('ConnectionConfig', () => {
assert.fail();
} catch (e) {
let groups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
let originalGroup = groups.find(g => g.id === 'g2');
let originalGroup = find(groups, g => g.id === 'g2');
assert.ok(!!originalGroup);
assert.equal(originalGroup.name, 'g2');
}
@@ -565,7 +566,7 @@ suite('ConnectionConfig', () => {
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
assert.equal(editedGroups.length, testGroups.length);
let editedGroup = editedGroups.find(group => group.id === 'g2');
let editedGroup = find(editedGroups, group => group.id === 'g2');
assert.ok(!!editedGroup);
assert.equal(editedGroup.parentId, 'g3');
});
@@ -622,7 +623,7 @@ suite('ConnectionConfig', () => {
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user;
// two
assert.equal(editedConnections.length, _testConnections.length);
let editedConnection = editedConnections.find(con => con.id === 'server3-2');
let editedConnection = find(editedConnections, con => con.id === 'server3-2');
assert.ok(!!editedConnection);
assert.equal(editedConnection.groupId, 'g3');
}
@@ -658,7 +659,7 @@ suite('ConnectionConfig', () => {
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user;
assert.equal(editedConnections.length, testConnections.length);
let editedConnection = editedConnections.find(con => con.id === 'server3');
let editedConnection = find(editedConnections, con => con.id === 'server3');
assert.ok(!!editedConnection);
assert.equal(editedConnection.groupId, 'newid');
});

View File

@@ -11,6 +11,7 @@ import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/ap
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
import { assign } from 'vs/base/common/objects';
suite('SQL ConnectionProfileInfo tests', () => {
let msSQLCapabilities: ConnectionProviderProperties;
@@ -187,7 +188,7 @@ suite('SQL ConnectionProfileInfo tests', () => {
});
test('createFromStoredProfile should set the id to new guid if not set in stored profile', () => {
let savedProfile = Object.assign({}, storedProfile, { id: undefined });
let savedProfile = assign({}, storedProfile, { id: undefined });
let connectionProfile = ConnectionProfile.createFromStoredProfile(savedProfile, capabilitiesService);
assert.equal(savedProfile.groupId, connectionProfile.groupId);
assert.deepEqual(savedProfile.providerName, connectionProfile.providerName);

View File

@@ -13,11 +13,12 @@ import { TestConfigurationService } from 'sql/platform/connection/test/common/te
import { TestCredentialsService } from 'sql/platform/credentials/test/common/testCredentialsService';
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
import { deepClone, deepFreeze } from 'vs/base/common/objects';
import { deepClone, deepFreeze, assign } from 'vs/base/common/objects';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
import { InMemoryStorageService } from 'vs/platform/storage/common/storage';
import { find } from 'vs/base/common/arrays';
suite('ConnectionStore', () => {
let defaultNamedProfile: IConnectionProfile = deepFreeze({
@@ -153,7 +154,7 @@ suite('ConnectionStore', () => {
const connectionStore = new ConnectionStore(storageService, configurationService,
credentialsService, capabilitiesService);
for (let i = 0; i < numCreds; i++) {
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
await connectionStore.addRecentConnection(connectionProfile);
const current = connectionStore.getRecentlyUsedConnections();
@@ -189,7 +190,7 @@ suite('ConnectionStore', () => {
// Then expect the only 1 instance of that connection to be listed in the MRU
const connectionStore = new ConnectionStore(storageService, configurationService,
credentialsService, capabilitiesService);
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + 1 });
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + 1 });
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
await connectionStore.addRecentConnection(defaultNamedConnectionProfile);
await connectionStore.addRecentConnection(connectionProfile);
@@ -211,13 +212,13 @@ suite('ConnectionStore', () => {
// Given we save 1 connection with password and multiple other connections without
const connectionStore = new ConnectionStore(storageService, configurationService,
credentialsService, capabilitiesService);
const integratedCred = Object.assign({}, defaultNamedProfile, {
const integratedCred = assign({}, defaultNamedProfile, {
serverName: defaultNamedProfile.serverName + 'Integrated',
authenticationType: 'Integrated',
userName: '',
password: ''
});
const noPwdCred = Object.assign({}, defaultNamedProfile, {
const noPwdCred = assign({}, defaultNamedProfile, {
serverName: defaultNamedProfile.serverName + 'NoPwd',
password: ''
});
@@ -232,7 +233,7 @@ suite('ConnectionStore', () => {
// Then verify that since its password based we save the password
assert.equal(credentialsService.credentials.size, 1);
assert.strictEqual(recentCredential.password, defaultNamedProfile.password);
assert.ok(recentCredential.credentialId.includes('Profile'), 'Expect credential to be marked as an Profile cred');
assert.ok(recentCredential.credentialId.indexOf('Profile') > -1, 'Expect credential to be marked as an Profile cred');
assert.ok(!current[0].password);
// When add integrated auth connection
const integratedCredConnectionProfile = new ConnectionProfile(capabilitiesService, integratedCred);
@@ -312,7 +313,7 @@ suite('ConnectionStore', () => {
const connectionStore = new ConnectionStore(storageService, configurationService,
credentialsService, capabilitiesService);
const connectionProfile: IConnectionProfile = Object.assign({}, defaultNamedProfile, { providerName: providerName });
const connectionProfile: IConnectionProfile = assign({}, defaultNamedProfile, { providerName: providerName });
assert.ok(!connectionStore.isPasswordRequired(connectionProfile));
});
@@ -323,7 +324,7 @@ suite('ConnectionStore', () => {
const credentialsService = new TestCredentialsService();
const password: string = 'asdf!@#$';
const connectionProfile: IConnectionProfile = Object.assign({}, defaultNamedProfile, { password });
const connectionProfile: IConnectionProfile = assign({}, defaultNamedProfile, { password });
const connectionStore = new ConnectionStore(storageService, configurationService,
credentialsService, capabilitiesService);
@@ -393,7 +394,7 @@ suite('ConnectionStore', () => {
const profile = deepClone(defaultNamedProfile);
profile.options['password'] = profile.password;
profile.id = 'testId';
let expectedProfile = Object.assign({}, profile);
let expectedProfile = assign({}, profile);
expectedProfile.password = '';
expectedProfile.options['password'] = '';
expectedProfile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, expectedProfile).toIConnectionProfile();
@@ -406,7 +407,7 @@ suite('ConnectionStore', () => {
const configurationService = new TestConfigurationService();
const credentialsService = new TestCredentialsService();
const profile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, Object.assign({}, defaultNamedProfile, { password: undefined }));
const profile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, assign({}, defaultNamedProfile, { password: undefined }));
const credId = `Microsoft.SqlTools|itemtype:Profile|id:${profile.getConnectionInfoId()}`;
const password: string = 'asdf!@#$';
@@ -453,7 +454,7 @@ suite('ConnectionStore', () => {
const connectionGroups = connectionStore.getConnectionProfileGroups();
for (const group of connectionGroups) {
const foundGroup = groups.find(g => g.id === group.id);
const foundGroup = find(groups, g => g.id === group.id);
assert.ok(foundGroup);
}
});
@@ -467,7 +468,7 @@ suite('ConnectionStore', () => {
credentialsService, capabilitiesService);
for (let i = 0; i < 5; i++) {
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
await connectionStore.addRecentConnection(connectionProfile);
const current = connectionStore.getRecentlyUsedConnections();
@@ -475,7 +476,7 @@ suite('ConnectionStore', () => {
}
for (let i = 0; i < 5; i++) {
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
connectionStore.removeRecentConnection(connectionProfile);
const current = connectionStore.getRecentlyUsedConnections();

View File

@@ -10,6 +10,7 @@ import * as assert from 'assert';
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { assign } from 'vs/base/common/objects';
suite('SQL ProviderConnectionInfo tests', () => {
let msSQLCapabilities: any;
@@ -202,7 +203,7 @@ suite('SQL ProviderConnectionInfo tests', () => {
test('constructor should initialize the options given a valid model with options', () => {
let options = {};
options['encrypt'] = 'test value';
let conn2 = Object.assign({}, connectionProfile, { options: options });
let conn2 = assign({}, connectionProfile, { options: options });
let conn = new ProviderConnectionInfo(capabilitiesService, conn2);
assert.equal(conn.connectionName, conn2.connectionName);
@@ -223,7 +224,7 @@ suite('SQL ProviderConnectionInfo tests', () => {
test('getOptionsKey should create different id for different server names', () => {
let conn = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
let conn2 = new ProviderConnectionInfo(capabilitiesService, Object.assign({}, connectionProfile, { serverName: connectionProfile.serverName + '1' }));
let conn2 = new ProviderConnectionInfo(capabilitiesService, assign({}, connectionProfile, { serverName: connectionProfile.serverName + '1' }));
assert.notEqual(conn.getOptionsKey(), conn2.getOptionsKey());
});
@@ -260,4 +261,4 @@ suite('SQL ProviderConnectionInfo tests', () => {
assert.equal(expectedProviderId, actual);
});
});
});

View File

@@ -15,6 +15,7 @@ import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { NullLogService } from 'vs/platform/log/common/log';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { assign } from 'vs/base/common/objects';
let connections: ConnectionStatusManager;
let capabilitiesService: TestCapabilitiesService;
@@ -171,7 +172,7 @@ suite('SQL ConnectionStatusManager tests', () => {
let expectedConnectionId = 'new id';
connections.addConnection(connectionProfile, connection1Id);
let updatedConnection = Object.assign({}, connectionProfile, { groupId: expected, getOptionsKey: () => connectionProfile.getOptionsKey() + expected, id: expectedConnectionId });
let updatedConnection = assign({}, connectionProfile, { groupId: expected, getOptionsKey: () => connectionProfile.getOptionsKey() + expected, id: expectedConnectionId });
let actualId = connections.updateConnectionProfile(updatedConnection, connection1Id);
let newId = Utils.generateUri(updatedConnection);
@@ -246,7 +247,7 @@ suite('SQL ConnectionStatusManager tests', () => {
test('getActiveConnectionProfiles should return a list of all the unique connections that the status manager knows about', () => {
// Add duplicate connections
let newConnection = Object.assign({}, connectionProfile);
let newConnection = assign({}, connectionProfile);
newConnection.id = 'test_id';
newConnection.serverName = 'new_server_name';
newConnection.options['databaseDisplayName'] = newConnection.databaseName;