Add back getOptionsKey test that was reverted (#23274)

* Add back getOptionsKey test that was reverted

* Add serverCapabilities to the IConnectionProfile object
This commit is contained in:
Karl Burtram
2023-05-31 17:59:18 -07:00
committed by GitHub
parent a7ed867066
commit b0c27baa15
12 changed files with 33 additions and 0 deletions

View File

@@ -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,

View File

@@ -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;

View File

@@ -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!,

View File

@@ -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());
});
});

View File

@@ -31,6 +31,7 @@ suite('ConnectionStore', () => {
savePassword: true,
groupId: '',
groupFullName: '',
serverCapabilities: undefined,
getOptionsKey: undefined!,
getOptionKeyIdNames: undefined!,
matches: () => false,

View File

@@ -23,6 +23,7 @@ suite('SQL ProviderConnectionInfo tests', () => {
authenticationType: '',
savePassword: true,
groupFullName: 'g2/g2-2',
serverCapabilities: undefined,
groupId: undefined,
getOptionsKey: undefined!,
getOptionKeyIdNames: undefined!,

View File

@@ -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!,