mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-25 17:23:10 -05:00
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:
@@ -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');
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user