From b0c27baa150893e2cb13a562b86f06d9760099cc Mon Sep 17 00:00:00 2001 From: Karl Burtram Date: Wed, 31 May 2023 17:59:18 -0700 Subject: [PATCH] Add back getOptionsKey test that was reverted (#23274) * Add back getOptionsKey test that was reverted * Add serverCapabilities to the IConnectionProfile object --- .../platform/connection/common/connectionProfile.ts | 1 + src/sql/platform/connection/common/interfaces.ts | 2 ++ .../connection/test/common/connectionConfig.test.ts | 12 ++++++++++++ .../connection/test/common/connectionProfile.test.ts | 7 +++++++ .../connection/test/common/connectionStore.test.ts | 1 + .../test/common/providerConnectionInfo.test.ts | 1 + .../test/node/connectionStatusManager.test.ts | 3 +++ .../test/browser/connectionManagementService.test.ts | 1 + .../test/browser/insightsDialogController.test.ts | 1 + .../test/browser/asyncServerTreeDragAndDrop.test.ts | 1 + .../test/browser/dragAndDropController.test.ts | 2 ++ .../browser/firewallRuleDialogController.test.ts | 1 + 12 files changed, 33 insertions(+) diff --git a/src/sql/platform/connection/common/connectionProfile.ts b/src/sql/platform/connection/common/connectionProfile.ts index 164bcbb3b8..eb976d16e9 100644 --- a/src/sql/platform/connection/common/connectionProfile.ts +++ b/src/sql/platform/connection/common/connectionProfile.ts @@ -253,6 +253,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa serverName: this.serverName, databaseName: this.databaseName, authenticationType: this.authenticationType, + serverCapabilities: this.serverCapabilities, getOptionsKey: this.getOptionsKey, getOptionKeyIdNames: this.getOptionKeyIdNames, matches: this.matches, diff --git a/src/sql/platform/connection/common/interfaces.ts b/src/sql/platform/connection/common/interfaces.ts index dee0027928..ae4f2ff52d 100644 --- a/src/sql/platform/connection/common/interfaces.ts +++ b/src/sql/platform/connection/common/interfaces.ts @@ -4,11 +4,13 @@ *--------------------------------------------------------------------------------------------*/ import * as azdata from 'azdata'; +import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService'; // Used to allow various methods of matching profiles export type ProfileMatcher = (a: IConnectionProfile, b: IConnectionProfile) => boolean; export interface IConnectionProfile extends azdata.IConnectionProfile { + serverCapabilities: ConnectionProviderProperties | undefined; getOptionsKey(): string; getOptionKeyIdNames(): string[]; matches(profile: azdata.IConnectionProfile): boolean; diff --git a/src/sql/platform/connection/test/common/connectionConfig.test.ts b/src/sql/platform/connection/test/common/connectionConfig.test.ts index 655c67fb26..a20c1adcda 100644 --- a/src/sql/platform/connection/test/common/connectionConfig.test.ts +++ b/src/sql/platform/connection/test/common/connectionConfig.test.ts @@ -276,6 +276,7 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: undefined, groupId: undefined, + serverCapabilities: undefined, getOptionsKey: undefined!, getOptionKeyIdNames: undefined!, matches: undefined!, @@ -309,6 +310,7 @@ suite('ConnectionConfig', () => { groupId: existingConnection.groupId, savePassword: true, groupFullName: undefined, + serverCapabilities: undefined, getOptionsKey: undefined!, getOptionKeyIdNames: undefined!, matches: undefined!, @@ -342,6 +344,7 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: 'g2/g2-2', groupId: undefined, + serverCapabilities: undefined, getOptionsKey: undefined!, getOptionKeyIdNames: undefined!, matches: undefined!, @@ -486,6 +489,7 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: 'g3', groupId: 'g3', + serverCapabilities: undefined, getOptionsKey: undefined!, getOptionKeyIdNames: undefined!, matches: undefined!, @@ -517,6 +521,7 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: 'g3', groupId: 'g3', + serverCapabilities: undefined, getOptionsKey: undefined!, getOptionKeyIdNames: undefined!, matches: undefined!, @@ -555,6 +560,7 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: 'g3', groupId: 'newid', + serverCapabilities: undefined, getOptionsKey: undefined!, getOptionKeyIdNames: undefined!, matches: undefined!, @@ -636,6 +642,7 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: 'g3', groupId: 'g3', + serverCapabilities: undefined, getOptionsKey: () => { return 'connectionId'; }, getOptionKeyIdNames: undefined!, matches: undefined!, @@ -654,6 +661,7 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: 'test', groupId: 'test', + serverCapabilities: undefined, getOptionsKey: () => { return 'connectionId'; }, getOptionKeyIdNames: undefined!, matches: undefined!, @@ -695,6 +703,7 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: 'g3', groupId: 'g3', + serverCapabilities: undefined, getOptionsKey: () => { return 'connectionId'; }, getOptionKeyIdNames: undefined!, matches: undefined!, @@ -799,6 +808,7 @@ suite('ConnectionConfig', () => { groupFullName: 'g3', groupId: 'g3', getOptionsKey: () => { return 'connectionId'; }, + serverCapabilities: undefined, getOptionKeyIdNames: undefined!, matches: undefined!, providerName: 'MSSQL', @@ -817,6 +827,7 @@ suite('ConnectionConfig', () => { groupFullName: 'test', groupId: 'test', getOptionsKey: () => { return 'connectionId'; }, + serverCapabilities: undefined, getOptionKeyIdNames: undefined!, matches: undefined!, providerName: 'MSSQL', @@ -834,6 +845,7 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: 'test', groupId: 'test', + serverCapabilities: undefined, getOptionsKey: () => { return 'connectionId'; }, getOptionKeyIdNames: undefined!, matches: undefined!, diff --git a/src/sql/platform/connection/test/common/connectionProfile.test.ts b/src/sql/platform/connection/test/common/connectionProfile.test.ts index c66d3791f2..c5258a29d5 100644 --- a/src/sql/platform/connection/test/common/connectionProfile.test.ts +++ b/src/sql/platform/connection/test/common/connectionProfile.test.ts @@ -25,6 +25,7 @@ suite('SQL ConnectionProfileInfo tests', () => { savePassword: true, groupFullName: 'g2/g2-2', groupId: 'group id', + serverCapabilities: undefined, getOptionsKey: undefined!, getOptionKeyIdNames: undefined!, matches: undefined!, @@ -282,4 +283,10 @@ suite('SQL ConnectionProfileInfo tests', () => { test('an empty connection profile does not cause issues', () => { assert.doesNotThrow(() => new ConnectionProfile(capabilitiesService, {} as IConnectionProfile)); }); + + test('getOptionsKey should produce the same optionsKey after converting to IConnectionProfile', () => { + let conn = new ConnectionProfile(capabilitiesService, iConnectionProfile); + const myIConnectionProfile = conn.toIConnectionProfile(); + assert.equal(conn.getOptionsKey(), myIConnectionProfile.getOptionsKey()); + }); }); diff --git a/src/sql/platform/connection/test/common/connectionStore.test.ts b/src/sql/platform/connection/test/common/connectionStore.test.ts index 1d4e63a584..5177f45075 100644 --- a/src/sql/platform/connection/test/common/connectionStore.test.ts +++ b/src/sql/platform/connection/test/common/connectionStore.test.ts @@ -31,6 +31,7 @@ suite('ConnectionStore', () => { savePassword: true, groupId: '', groupFullName: '', + serverCapabilities: undefined, getOptionsKey: undefined!, getOptionKeyIdNames: undefined!, matches: () => false, diff --git a/src/sql/platform/connection/test/common/providerConnectionInfo.test.ts b/src/sql/platform/connection/test/common/providerConnectionInfo.test.ts index 5457c8f067..c571a6e37c 100644 --- a/src/sql/platform/connection/test/common/providerConnectionInfo.test.ts +++ b/src/sql/platform/connection/test/common/providerConnectionInfo.test.ts @@ -23,6 +23,7 @@ suite('SQL ProviderConnectionInfo tests', () => { authenticationType: '', savePassword: true, groupFullName: 'g2/g2-2', + serverCapabilities: undefined, groupId: undefined, getOptionsKey: undefined!, getOptionKeyIdNames: undefined!, diff --git a/src/sql/platform/connection/test/node/connectionStatusManager.test.ts b/src/sql/platform/connection/test/node/connectionStatusManager.test.ts index 4761d0194a..28401eba1a 100644 --- a/src/sql/platform/connection/test/node/connectionStatusManager.test.ts +++ b/src/sql/platform/connection/test/node/connectionStatusManager.test.ts @@ -26,6 +26,7 @@ let connectionProfile: IConnectionProfile = { savePassword: true, groupFullName: 'g2/g2-2', groupId: 'group id', + serverCapabilities: undefined, getOptionsKey: () => 'connection1', getOptionKeyIdNames: undefined!, matches: undefined!, @@ -44,6 +45,7 @@ let editorConnectionProfile: IConnectionProfile = { savePassword: true, groupFullName: 'g2/g2-2', groupId: 'group id', + serverCapabilities: undefined, getOptionsKey: () => 'connection2', getOptionKeyIdNames: undefined!, matches: undefined!, @@ -62,6 +64,7 @@ let connectionProfileWithoutDbName: IConnectionProfile = { savePassword: true, groupFullName: 'g2/g2-2', groupId: 'group id', + serverCapabilities: undefined, getOptionsKey: () => 'connection1', getOptionKeyIdNames: undefined!, matches: undefined!, diff --git a/src/sql/workbench/services/connection/test/browser/connectionManagementService.test.ts b/src/sql/workbench/services/connection/test/browser/connectionManagementService.test.ts index 4ee46e5ae5..65fbaed290 100644 --- a/src/sql/workbench/services/connection/test/browser/connectionManagementService.test.ts +++ b/src/sql/workbench/services/connection/test/browser/connectionManagementService.test.ts @@ -67,6 +67,7 @@ suite('SQL ConnectionManagementService tests', () => { savePassword: true, groupFullName: 'g2/g2-2', groupId: 'group id', + serverCapabilities: undefined, getOptionsKey: () => { return 'connectionId'; }, getOptionKeyIdNames: undefined!, matches: undefined, diff --git a/src/sql/workbench/services/insights/test/browser/insightsDialogController.test.ts b/src/sql/workbench/services/insights/test/browser/insightsDialogController.test.ts index 155e3dd80d..2e6eeb4658 100644 --- a/src/sql/workbench/services/insights/test/browser/insightsDialogController.test.ts +++ b/src/sql/workbench/services/insights/test/browser/insightsDialogController.test.ts @@ -74,6 +74,7 @@ suite('Insights Dialog Controller Tests', () => { savePassword: true, groupFullName: '', groupId: '', + serverCapabilities: undefined, getOptionsKey: () => '', getOptionKeyIdNames: undefined!, matches: undefined, diff --git a/src/sql/workbench/services/objectExplorer/test/browser/asyncServerTreeDragAndDrop.test.ts b/src/sql/workbench/services/objectExplorer/test/browser/asyncServerTreeDragAndDrop.test.ts index 9a0a2922d8..fe9507ccf3 100644 --- a/src/sql/workbench/services/objectExplorer/test/browser/asyncServerTreeDragAndDrop.test.ts +++ b/src/sql/workbench/services/objectExplorer/test/browser/asyncServerTreeDragAndDrop.test.ts @@ -35,6 +35,7 @@ suite('AsyncServerTreeDragAndDrop', () => { savePassword: true, groupFullName: 'g2/g2-2', groupId: 'group id', + serverCapabilities: undefined, getOptionsKey: undefined!, getOptionKeyIdNames: undefined!, matches: undefined!, diff --git a/src/sql/workbench/services/objectExplorer/test/browser/dragAndDropController.test.ts b/src/sql/workbench/services/objectExplorer/test/browser/dragAndDropController.test.ts index 5ded395055..abea4a4e6d 100644 --- a/src/sql/workbench/services/objectExplorer/test/browser/dragAndDropController.test.ts +++ b/src/sql/workbench/services/objectExplorer/test/browser/dragAndDropController.test.ts @@ -40,6 +40,7 @@ suite('SQL Drag And Drop Controller tests', () => { savePassword: true, groupFullName: 'g2/g2-2', groupId: 'group id', + serverCapabilities: undefined, getOptionsKey: undefined!, getOptionKeyIdNames: undefined!, matches: undefined!, @@ -59,6 +60,7 @@ suite('SQL Drag And Drop Controller tests', () => { savePassword: true, groupFullName: 'g2/g2-2', groupId: 'group id', + serverCapabilities: undefined, getOptionsKey: undefined!, getOptionKeyIdNames: undefined!, matches: undefined!, diff --git a/src/sql/workbench/services/resourceProvider/test/browser/firewallRuleDialogController.test.ts b/src/sql/workbench/services/resourceProvider/test/browser/firewallRuleDialogController.test.ts index 8661211605..a0d6def3f0 100644 --- a/src/sql/workbench/services/resourceProvider/test/browser/firewallRuleDialogController.test.ts +++ b/src/sql/workbench/services/resourceProvider/test/browser/firewallRuleDialogController.test.ts @@ -88,6 +88,7 @@ suite('Firewall rule dialog controller tests', () => { savePassword: true, groupFullName: 'g2/g2-2', groupId: 'group id', + serverCapabilities: undefined, getOptionsKey: () => '', getOptionKeyIdNames: undefined!, matches: () => false,