mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-24 01:25:37 -05:00
Merge from vscode 4636be2b71c87bfb0bfe3c94278b447a5efcc1f1 (#8722)
* Merge from vscode 4636be2b71c87bfb0bfe3c94278b447a5efcc1f1 * remove tests that aren't working
This commit is contained in:
@@ -39,15 +39,15 @@ export class ConnectionConfig {
|
||||
|
||||
let allGroups: IConnectionProfileGroup[] = [];
|
||||
const config = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY);
|
||||
let { user } = config;
|
||||
const { workspace } = config;
|
||||
let { userValue } = config;
|
||||
const { workspaceValue } = config;
|
||||
|
||||
if (user) {
|
||||
if (workspace) {
|
||||
user = user.filter(x => find(workspace, f => this.isSameGroupName(f, x)) === undefined);
|
||||
allGroups = allGroups.concat(workspace);
|
||||
if (userValue) {
|
||||
if (workspaceValue) {
|
||||
userValue = userValue.filter(x => find(workspaceValue, f => this.isSameGroupName(f, x)) === undefined);
|
||||
allGroups = allGroups.concat(workspaceValue);
|
||||
}
|
||||
allGroups = allGroups.concat(user);
|
||||
allGroups = allGroups.concat(userValue);
|
||||
}
|
||||
return allGroups.map(g => {
|
||||
if (g.parentId === '' || !g.parentId) {
|
||||
@@ -63,7 +63,7 @@ export class ConnectionConfig {
|
||||
public addConnection(profile: IConnectionProfile): Promise<IConnectionProfile> {
|
||||
if (profile.saveProfile) {
|
||||
return this.addGroupFromProfile(profile).then(groupId => {
|
||||
let profiles = this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).user;
|
||||
let profiles = this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).userValue;
|
||||
if (!profiles) {
|
||||
profiles = [];
|
||||
}
|
||||
@@ -108,7 +108,7 @@ export class ConnectionConfig {
|
||||
if (profile.groupId && profile.groupId !== Utils.defaultGroupId) {
|
||||
return Promise.resolve(profile.groupId);
|
||||
} else {
|
||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).user;
|
||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).userValue;
|
||||
let result = this.saveGroup(groups!, profile.groupFullName, undefined, undefined);
|
||||
groups = result.groups;
|
||||
|
||||
@@ -123,7 +123,7 @@ export class ConnectionConfig {
|
||||
if (profileGroup.id) {
|
||||
return Promise.resolve(profileGroup.id);
|
||||
} else {
|
||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).user;
|
||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).userValue;
|
||||
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.");
|
||||
@@ -143,9 +143,9 @@ export class ConnectionConfig {
|
||||
if (configs) {
|
||||
let fromConfig: IConnectionProfileStore[] | undefined;
|
||||
if (configTarget === ConfigurationTarget.USER) {
|
||||
fromConfig = configs.user;
|
||||
fromConfig = configs.userValue;
|
||||
} else if (configTarget === ConfigurationTarget.WORKSPACE) {
|
||||
fromConfig = configs.workspace || [];
|
||||
fromConfig = configs.workspaceValue || [];
|
||||
}
|
||||
if (fromConfig) {
|
||||
profiles = fromConfig;
|
||||
@@ -218,7 +218,7 @@ export class ConnectionConfig {
|
||||
*/
|
||||
public deleteConnection(profile: ConnectionProfile): Promise<void> {
|
||||
// Get all connections in the settings
|
||||
let profiles = this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).user;
|
||||
let profiles = this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).userValue;
|
||||
// Remove the profile from the connections
|
||||
profiles = profiles!.filter(value => {
|
||||
let providerConnectionProfile = ConnectionProfile.createFromStoredProfile(value, this._capabilitiesService);
|
||||
@@ -239,7 +239,7 @@ export class ConnectionConfig {
|
||||
// Add selected group to subgroups list
|
||||
subgroups.push(group);
|
||||
// Get all connections in the settings
|
||||
let profiles = this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).user;
|
||||
let profiles = this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).userValue;
|
||||
// Remove the profiles from the connections
|
||||
profiles = profiles!.filter(value => {
|
||||
let providerConnectionProfile = ConnectionProfile.createFromStoredProfile(value, this._capabilitiesService);
|
||||
@@ -247,7 +247,7 @@ export class ConnectionConfig {
|
||||
});
|
||||
|
||||
// Get all groups in the settings
|
||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).user;
|
||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).userValue;
|
||||
// Remove subgroups in the settings
|
||||
groups = groups!.filter((grp) => {
|
||||
return !subgroups.some((item) => item.id === grp.id);
|
||||
@@ -262,7 +262,7 @@ export class ConnectionConfig {
|
||||
* Moves the source group under the target group.
|
||||
*/
|
||||
public changeGroupIdForConnectionGroup(source: ConnectionProfileGroup, target: ConnectionProfileGroup): Promise<void> {
|
||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).user;
|
||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).userValue;
|
||||
groups = groups!.map(g => {
|
||||
if (g.id === source.id) {
|
||||
g.parentId = target.id;
|
||||
@@ -286,8 +286,8 @@ export class ConnectionConfig {
|
||||
* Moves the connection under the target group with the new ID.
|
||||
*/
|
||||
private changeGroupIdForConnectionInSettings(profile: ConnectionProfile, newGroupID: string, target: ConfigurationTarget = ConfigurationTarget.USER): Promise<void> {
|
||||
let profiles = target === ConfigurationTarget.USER ? this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).user :
|
||||
this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).workspace;
|
||||
let profiles = target === ConfigurationTarget.USER ? this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).userValue :
|
||||
this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).workspaceValue;
|
||||
if (profiles) {
|
||||
if (profile.parent && profile.parent.id === UNSAVED_GROUP_ID) {
|
||||
profile.groupId = newGroupID;
|
||||
@@ -328,7 +328,7 @@ export class ConnectionConfig {
|
||||
}
|
||||
|
||||
public editGroup(source: ConnectionProfileGroup): Promise<void> {
|
||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).user;
|
||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).userValue;
|
||||
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.");
|
||||
|
||||
@@ -269,7 +269,7 @@ suite('ConnectionConfig', () => {
|
||||
let savedConnectionProfile = await config.addConnection(connectionProfile);
|
||||
|
||||
assert.ok(!!savedConnectionProfile.id);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user.length, testConnections.length + 1);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue.length, testConnections.length + 1);
|
||||
});
|
||||
|
||||
test('addConnection should not add the new profile to user settings if already exists', async () => {
|
||||
@@ -303,7 +303,7 @@ suite('ConnectionConfig', () => {
|
||||
let savedConnectionProfile = await config.addConnection(connectionProfile);
|
||||
|
||||
assert.equal(savedConnectionProfile.id, existingConnection.id);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user.length, testConnections.length);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue.length, testConnections.length);
|
||||
});
|
||||
|
||||
test('addConnection should add the new group to user settings if does not exist', async () => {
|
||||
@@ -333,8 +333,8 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
await config.addConnection(connectionProfile);
|
||||
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user.length, testConnections.length + 1);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connectionGroups').user.length, testGroups.length + 1);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue.length, testConnections.length + 1);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connectionGroups').userValue.length, testGroups.length + 1);
|
||||
});
|
||||
|
||||
test('getConnections should return connections from user and workspace settings given getWorkspaceConnections set to true', () => {
|
||||
@@ -452,7 +452,7 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
await config.deleteConnection(connectionProfile);
|
||||
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user.length, testConnections.length - 1);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue.length, testConnections.length - 1);
|
||||
});
|
||||
|
||||
test('deleteConnectionGroup should remove the children connections and subgroups from config', async () => {
|
||||
@@ -488,8 +488,8 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
await config.deleteGroup(connectionProfileGroup);
|
||||
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user.length, testConnections.length - 1);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user.length, testGroups.length - 2);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue.length, testConnections.length - 1);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue.length, testGroups.length - 2);
|
||||
});
|
||||
|
||||
test('deleteConnection should not throw error for connection not in config', async () => {
|
||||
@@ -517,7 +517,7 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
await config.deleteConnection(connectionProfile);
|
||||
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user.length, testConnections.length);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue.length, testConnections.length);
|
||||
});
|
||||
|
||||
test('renameGroup should change group name', async () => {
|
||||
@@ -528,7 +528,7 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
await config.editGroup(connectionProfileGroup);
|
||||
|
||||
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
|
||||
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue;
|
||||
|
||||
assert.equal(editedGroups.length, testGroups.length);
|
||||
let editedGroup = find(editedGroups, group => group.id === 'g2');
|
||||
@@ -547,7 +547,7 @@ suite('ConnectionConfig', () => {
|
||||
await config.editGroup(sameNameGroup);
|
||||
assert.fail();
|
||||
} catch (e) {
|
||||
let groups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
|
||||
let groups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue;
|
||||
let originalGroup = find(groups, g => g.id === 'g2');
|
||||
assert.ok(!!originalGroup);
|
||||
assert.equal(originalGroup.name, 'g2');
|
||||
@@ -563,7 +563,7 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
await config.changeGroupIdForConnectionGroup(sourceProfileGroup, targetProfileGroup);
|
||||
|
||||
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
|
||||
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue;
|
||||
|
||||
assert.equal(editedGroups.length, testGroups.length);
|
||||
let editedGroup = find(editedGroups, group => group.id === 'g2');
|
||||
@@ -620,7 +620,7 @@ suite('ConnectionConfig', () => {
|
||||
await config.changeGroupIdForConnection(connectionProfile, 'test');
|
||||
assert.fail();
|
||||
} catch (e) {
|
||||
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user;
|
||||
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue;
|
||||
// two
|
||||
assert.equal(editedConnections.length, _testConnections.length);
|
||||
let editedConnection = find(editedConnections, con => con.id === 'server3-2');
|
||||
@@ -657,7 +657,7 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
await config.changeGroupIdForConnection(connectionProfile, newId);
|
||||
|
||||
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user;
|
||||
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue;
|
||||
assert.equal(editedConnections.length, testConnections.length);
|
||||
let editedConnection = find(editedConnections, con => con.id === 'server3');
|
||||
assert.ok(!!editedConnection);
|
||||
@@ -704,7 +704,7 @@ suite('ConnectionConfig', () => {
|
||||
|
||||
await config.addGroup(newGroup);
|
||||
|
||||
let editGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
|
||||
let editGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue;
|
||||
|
||||
assert.equal(editGroups.length, testGroups.length + 1);
|
||||
});
|
||||
@@ -725,7 +725,7 @@ suite('ConnectionConfig', () => {
|
||||
await config.addGroup(existingGroupName);
|
||||
assert.fail();
|
||||
} catch (e) {
|
||||
let editGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
|
||||
let editGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue;
|
||||
|
||||
assert.equal(editGroups.length, testGroups.length);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { getConfigurationKeys, IConfigurationOverrides, IConfigurationService, getConfigurationValue, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { getConfigurationKeys, IConfigurationOverrides, IConfigurationService, getConfigurationValue, ConfigurationTarget, IConfigurationValue } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
export class TestConfigurationService implements IConfigurationService {
|
||||
public _serviceBrand: undefined;
|
||||
@@ -42,19 +42,13 @@ export class TestConfigurationService implements IConfigurationService {
|
||||
return { dispose() { } };
|
||||
}
|
||||
|
||||
public inspect<T>(key: string, overrides?: IConfigurationOverrides): {
|
||||
default: T,
|
||||
user: T,
|
||||
workspace?: T,
|
||||
workspaceFolder?: T
|
||||
value: T,
|
||||
} {
|
||||
public inspect<T>(key: string, overrides?: IConfigurationOverrides): IConfigurationValue<T> {
|
||||
|
||||
return {
|
||||
value: getConfigurationValue<T>(this.configuration.user, key),
|
||||
default: undefined,
|
||||
user: getConfigurationValue<T>(this.configuration.user, key),
|
||||
workspace: getConfigurationValue<T>(this.configuration.workspace, key),
|
||||
userValue: getConfigurationValue<T>(this.configuration.user, key),
|
||||
workspaceValue: getConfigurationValue<T>(this.configuration.workspace, key),
|
||||
workspaceFolder: undefined
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { IGridDataProvider, getResultsString } from 'sql/platform/query/common/gridDataProvider';
|
||||
|
||||
Reference in New Issue
Block a user