mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 01:25:38 -05:00
Replace deprecated assert functions in test files. (#16945)
This commit is contained in:
@@ -235,7 +235,7 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
let allGroups = config.getAllGroups();
|
||||
|
||||
assert.equal(allGroups.length, testGroups.length, 'did not meet the expected length');
|
||||
assert.strictEqual(allGroups.length, testGroups.length, 'did not meet the expected length');
|
||||
assert.ok(groupsAreEqual(allGroups, testGroups), 'the groups returned did not match expectation');
|
||||
});
|
||||
|
||||
@@ -248,7 +248,7 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
let allGroups = config.getAllGroups();
|
||||
|
||||
assert.equal(allGroups.length, testGroups.length, 'did not meet the expected length');
|
||||
assert.strictEqual(allGroups.length, testGroups.length, 'did not meet the expected length');
|
||||
assert.ok(groupsAreEqual(allGroups, testGroups), 'the groups returned did not match expectation');
|
||||
assert.ok(allGroups.slice(1).every((item, i) => allGroups[i].name <= item.name), 'the groups are not sorted correctly');
|
||||
});
|
||||
@@ -262,7 +262,7 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
let allGroups = config.getAllGroups();
|
||||
let expectedGroups = deepClone(testGroups).slice(0, 3).reverse().concat(deepClone(testGroups).slice(3, testGroups.length).reverse());
|
||||
assert.equal(allGroups.length, expectedGroups.length, 'The result groups length is invalid');
|
||||
assert.strictEqual(allGroups.length, expectedGroups.length, 'The result groups length is invalid');
|
||||
assert.ok(allGroups.every((item, i) => item.id === allGroups[i].id));
|
||||
});
|
||||
|
||||
@@ -294,7 +294,7 @@ suite('ConnectionConfig', () => {
|
||||
let savedConnectionProfile = await config.addConnection(connectionProfile);
|
||||
|
||||
assert.ok(!!savedConnectionProfile.id);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length + 1);
|
||||
assert.strictEqual(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 () => {
|
||||
@@ -327,8 +327,8 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
let savedConnectionProfile = await config.addConnection(connectionProfile);
|
||||
|
||||
assert.equal(savedConnectionProfile.id, existingConnection.id);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length);
|
||||
assert.strictEqual(savedConnectionProfile.id, existingConnection.id);
|
||||
assert.strictEqual(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length);
|
||||
});
|
||||
|
||||
test('addConnection should add the new group to user settings if does not exist', async () => {
|
||||
@@ -358,8 +358,8 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
await config.addConnection(connectionProfile);
|
||||
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length + 1);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connectionGroups').userValue!.length, testGroups.length + 1);
|
||||
assert.strictEqual(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length + 1);
|
||||
assert.strictEqual(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', () => {
|
||||
@@ -369,7 +369,7 @@ suite('ConnectionConfig', () => {
|
||||
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
let allConnections = config.getConnections(true);
|
||||
assert.equal(allConnections.length, testConnections.length);
|
||||
assert.strictEqual(allConnections.length, testConnections.length);
|
||||
});
|
||||
|
||||
test('getConnections should return connections from user settings given getWorkspaceConnections set to false', () => {
|
||||
@@ -379,7 +379,7 @@ suite('ConnectionConfig', () => {
|
||||
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
let allConnections = config.getConnections(false);
|
||||
assert.equal(allConnections.length, 2);
|
||||
assert.strictEqual(allConnections.length, 2);
|
||||
});
|
||||
|
||||
test('getConnections should return connections with a valid id', () => {
|
||||
@@ -397,16 +397,16 @@ suite('ConnectionConfig', () => {
|
||||
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
let allConnections = config.getConnections(false);
|
||||
assert.equal(allConnections.length, testConnections.length);
|
||||
assert.strictEqual(allConnections.length, testConnections.length);
|
||||
allConnections.forEach(connection => {
|
||||
let userConnection = testConnections.find(u => u.options['serverName'] === connection.serverName);
|
||||
if (userConnection !== undefined) {
|
||||
assert.notEqual(connection.id, connection.getOptionsKey());
|
||||
assert.notStrictEqual(connection.id, connection.getOptionsKey());
|
||||
assert.ok(!!connection.id);
|
||||
} else {
|
||||
let workspaceConnection = workspaceConnections.find(u => u.options['serverName'] === connection.serverName);
|
||||
assert.notEqual(connection.id, connection.getOptionsKey());
|
||||
assert.equal(workspaceConnection!.id, connection.id);
|
||||
assert.notStrictEqual(connection.id, connection.getOptionsKey());
|
||||
assert.strictEqual(workspaceConnection!.id, connection.id);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -419,7 +419,7 @@ suite('ConnectionConfig', () => {
|
||||
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
let allConnections = config.getConnections(true);
|
||||
assert.equal(allConnections.length, testConnections.length, 'The result connections length is invalid');
|
||||
assert.strictEqual(allConnections.length, testConnections.length, 'The result connections length is invalid');
|
||||
assert.ok(allConnections.slice(1).every((item, i) => allConnections[i].title <= item.title), 'The connections are not sorted correctly');
|
||||
});
|
||||
|
||||
@@ -431,7 +431,7 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
let allConnections = config.getConnections(false);
|
||||
let expectedConnections = deepClone(testConnections).reverse();
|
||||
assert.equal(allConnections.length, expectedConnections.length, 'The result connections length is invalid');
|
||||
assert.strictEqual(allConnections.length, expectedConnections.length, 'The result connections length is invalid');
|
||||
assert.ok(allConnections.every((item, i) => item.id === expectedConnections[i].id));
|
||||
});
|
||||
|
||||
@@ -443,9 +443,9 @@ 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');
|
||||
assert.strictEqual(result.groups.length, testGroups.length + 2, 'The result groups length is invalid');
|
||||
let newGroup = result.groups.find(g => g.name === 'new-group2');
|
||||
assert.equal(result.newGroupId, newGroup!.id, 'The groups id is invalid');
|
||||
assert.strictEqual(result.newGroupId, newGroup!.id, 'The groups id is invalid');
|
||||
});
|
||||
|
||||
test('saveGroup should only add the groups that are not in the tree', () => {
|
||||
@@ -456,9 +456,9 @@ 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');
|
||||
assert.strictEqual(result.groups.length, testGroups.length + 1, 'The result groups length is invalid');
|
||||
let newGroup = result.groups.find(g => g.name === 'g2-5');
|
||||
assert.equal(result.newGroupId, newGroup!.id, 'The groups id is invalid');
|
||||
assert.strictEqual(result.newGroupId, newGroup!.id, 'The groups id is invalid');
|
||||
});
|
||||
|
||||
test('saveGroup should not add any new group if tree already has all the groups in the full path', () => {
|
||||
@@ -469,9 +469,9 @@ 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');
|
||||
assert.strictEqual(result.groups.length, testGroups.length, 'The result groups length is invalid');
|
||||
let newGroup = result.groups.find(g => g.name === 'g2-1');
|
||||
assert.equal(result.newGroupId, newGroup!.id, 'The groups id is invalid');
|
||||
assert.strictEqual(result.newGroupId, newGroup!.id, 'The groups id is invalid');
|
||||
});
|
||||
|
||||
test('deleteConnection should remove the connection from config', async () => {
|
||||
@@ -501,7 +501,7 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
await config.deleteConnection(connectionProfile);
|
||||
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length - 1);
|
||||
assert.strictEqual(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length - 1);
|
||||
});
|
||||
|
||||
test('deleteConnectionGroup should remove the children connections and subgroups from config', async () => {
|
||||
@@ -537,8 +537,8 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
await config.deleteGroup(connectionProfileGroup);
|
||||
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length - 1);
|
||||
assert.equal(configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue!.length, testGroups.length - 2);
|
||||
assert.strictEqual(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length - 1);
|
||||
assert.strictEqual(configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue!.length, testGroups.length - 2);
|
||||
});
|
||||
|
||||
test('deleteConnection should not throw error for connection not in config', async () => {
|
||||
@@ -566,7 +566,7 @@ suite('ConnectionConfig', () => {
|
||||
let config = new ConnectionConfig(configurationService, capabilitiesService.object);
|
||||
await config.deleteConnection(connectionProfile);
|
||||
|
||||
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length);
|
||||
assert.strictEqual(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length);
|
||||
});
|
||||
|
||||
test('renameGroup should change group name', async () => {
|
||||
@@ -579,10 +579,10 @@ suite('ConnectionConfig', () => {
|
||||
|
||||
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue!;
|
||||
|
||||
assert.equal(editedGroups.length, testGroups.length);
|
||||
assert.strictEqual(editedGroups.length, testGroups.length);
|
||||
let editedGroup = editedGroups.find(group => group.id === 'g2');
|
||||
assert.ok(!!editedGroup);
|
||||
assert.equal(editedGroup!.name, 'g-renamed');
|
||||
assert.strictEqual(editedGroup!.name, 'g-renamed');
|
||||
});
|
||||
|
||||
test('edit group should throw if there is a confliction', async () => {
|
||||
@@ -599,7 +599,7 @@ suite('ConnectionConfig', () => {
|
||||
let groups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue!;
|
||||
let originalGroup = groups.find(g => g.id === 'g2');
|
||||
assert.ok(!!originalGroup);
|
||||
assert.equal(originalGroup!.name, 'g2');
|
||||
assert.strictEqual(originalGroup!.name, 'g2');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -614,10 +614,10 @@ suite('ConnectionConfig', () => {
|
||||
|
||||
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue!;
|
||||
|
||||
assert.equal(editedGroups.length, testGroups.length);
|
||||
assert.strictEqual(editedGroups.length, testGroups.length);
|
||||
let editedGroup = editedGroups.find(group => group.id === 'g2');
|
||||
assert.ok(!!editedGroup);
|
||||
assert.equal(editedGroup!.parentId, 'g3');
|
||||
assert.strictEqual(editedGroup!.parentId, 'g3');
|
||||
});
|
||||
|
||||
|
||||
@@ -671,10 +671,10 @@ suite('ConnectionConfig', () => {
|
||||
} catch (e) {
|
||||
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!;
|
||||
// two
|
||||
assert.equal(editedConnections.length, _testConnections.length);
|
||||
assert.strictEqual(editedConnections.length, _testConnections.length);
|
||||
let editedConnection = editedConnections.find(con => con.id === 'server3-2');
|
||||
assert.ok(!!editedConnection);
|
||||
assert.equal(editedConnection!.groupId, 'g3');
|
||||
assert.strictEqual(editedConnection!.groupId, 'g3');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -707,10 +707,10 @@ suite('ConnectionConfig', () => {
|
||||
await config.changeGroupIdForConnection(connectionProfile, newId);
|
||||
|
||||
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!;
|
||||
assert.equal(editedConnections.length, testConnections.length);
|
||||
assert.strictEqual(editedConnections.length, testConnections.length);
|
||||
let editedConnection = editedConnections.find(con => con.id === 'server3');
|
||||
assert.ok(!!editedConnection);
|
||||
assert.equal(editedConnection!.groupId, 'newid');
|
||||
assert.strictEqual(editedConnection!.groupId, 'newid');
|
||||
});
|
||||
|
||||
test('addConnection should not move the connection when editing', async () => {
|
||||
@@ -732,10 +732,10 @@ suite('ConnectionConfig', () => {
|
||||
|
||||
// Get the connection and verify that it is in the same place and has been updated
|
||||
let newConnections = config.getConnections(false);
|
||||
assert.equal(newConnections.length, oldLength);
|
||||
assert.strictEqual(newConnections.length, oldLength);
|
||||
let editedConnection = newConnections[connectionIndex];
|
||||
assert.equal(editedConnection.getOptionsKey(), connectionToEdit.getOptionsKey());
|
||||
assert.equal(editedConnection.options[optionKey], optionValue);
|
||||
assert.strictEqual(editedConnection.getOptionsKey(), connectionToEdit.getOptionsKey());
|
||||
assert.strictEqual(editedConnection.options[optionKey], optionValue);
|
||||
});
|
||||
|
||||
test('addgroup works', async () => {
|
||||
@@ -755,7 +755,7 @@ suite('ConnectionConfig', () => {
|
||||
|
||||
let editGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue!;
|
||||
|
||||
assert.equal(editGroups.length, testGroups.length + 1);
|
||||
assert.strictEqual(editGroups.length, testGroups.length + 1);
|
||||
});
|
||||
|
||||
test('addGroup rejects if group name already exists', async () => {
|
||||
@@ -776,7 +776,7 @@ suite('ConnectionConfig', () => {
|
||||
} catch (e) {
|
||||
let editGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue!;
|
||||
|
||||
assert.equal(editGroups.length, testGroups.length);
|
||||
assert.strictEqual(editGroups.length, testGroups.length);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -134,7 +134,7 @@ suite('SQL ConnectionProfileInfo tests', () => {
|
||||
|
||||
test('set properties should set the values correctly', () => {
|
||||
let conn = new ConnectionProfile(capabilitiesService, undefined!);
|
||||
assert.equal(conn.serverName, undefined);
|
||||
assert.strictEqual(conn.serverName, undefined);
|
||||
conn.connectionName = connectionProfile.connectionName!;
|
||||
conn.serverName = connectionProfile.serverName;
|
||||
conn.databaseName = connectionProfile.databaseName!;
|
||||
@@ -144,75 +144,75 @@ suite('SQL ConnectionProfileInfo tests', () => {
|
||||
conn.groupId = connectionProfile.groupId;
|
||||
conn.groupFullName = connectionProfile.groupFullName;
|
||||
conn.savePassword = connectionProfile.savePassword;
|
||||
assert.equal(conn.connectionName, connectionProfile.connectionName);
|
||||
assert.equal(conn.serverName, connectionProfile.serverName);
|
||||
assert.equal(conn.databaseName, connectionProfile.databaseName);
|
||||
assert.equal(conn.authenticationType, connectionProfile.authenticationType);
|
||||
assert.equal(conn.password, connectionProfile.password);
|
||||
assert.equal(conn.userName, connectionProfile.userName);
|
||||
assert.equal(conn.groupId, connectionProfile.groupId);
|
||||
assert.equal(conn.groupFullName, connectionProfile.groupFullName);
|
||||
assert.equal(conn.savePassword, connectionProfile.savePassword);
|
||||
assert.strictEqual(conn.connectionName, connectionProfile.connectionName);
|
||||
assert.strictEqual(conn.serverName, connectionProfile.serverName);
|
||||
assert.strictEqual(conn.databaseName, connectionProfile.databaseName);
|
||||
assert.strictEqual(conn.authenticationType, connectionProfile.authenticationType);
|
||||
assert.strictEqual(conn.password, connectionProfile.password);
|
||||
assert.strictEqual(conn.userName, connectionProfile.userName);
|
||||
assert.strictEqual(conn.groupId, connectionProfile.groupId);
|
||||
assert.strictEqual(conn.groupFullName, connectionProfile.groupFullName);
|
||||
assert.strictEqual(conn.savePassword, connectionProfile.savePassword);
|
||||
});
|
||||
|
||||
test('constructor should initialize the options given a valid model', () => {
|
||||
let conn = new ConnectionProfile(capabilitiesService, connectionProfile);
|
||||
|
||||
assert.equal(conn.connectionName, connectionProfile.connectionName);
|
||||
assert.equal(conn.serverName, connectionProfile.serverName);
|
||||
assert.equal(conn.databaseName, connectionProfile.databaseName);
|
||||
assert.equal(conn.authenticationType, connectionProfile.authenticationType);
|
||||
assert.equal(conn.password, connectionProfile.password);
|
||||
assert.equal(conn.userName, connectionProfile.userName);
|
||||
assert.equal(conn.groupId, connectionProfile.groupId);
|
||||
assert.equal(conn.groupFullName, connectionProfile.groupFullName);
|
||||
assert.equal(conn.savePassword, connectionProfile.savePassword);
|
||||
assert.strictEqual(conn.connectionName, connectionProfile.connectionName);
|
||||
assert.strictEqual(conn.serverName, connectionProfile.serverName);
|
||||
assert.strictEqual(conn.databaseName, connectionProfile.databaseName);
|
||||
assert.strictEqual(conn.authenticationType, connectionProfile.authenticationType);
|
||||
assert.strictEqual(conn.password, connectionProfile.password);
|
||||
assert.strictEqual(conn.userName, connectionProfile.userName);
|
||||
assert.strictEqual(conn.groupId, connectionProfile.groupId);
|
||||
assert.strictEqual(conn.groupFullName, connectionProfile.groupFullName);
|
||||
assert.strictEqual(conn.savePassword, connectionProfile.savePassword);
|
||||
});
|
||||
|
||||
test('getOptionsKey should create a valid unique id', () => {
|
||||
let conn = new ConnectionProfile(capabilitiesService, connectionProfile);
|
||||
let expectedId = 'providerName:MSSQL|authenticationType:|databaseName:database|serverName:new server|userName:user|databaseDisplayName:database|group:group id';
|
||||
let id = conn.getOptionsKey();
|
||||
assert.equal(id, expectedId);
|
||||
assert.strictEqual(id, expectedId);
|
||||
});
|
||||
|
||||
test('createFromStoredProfile should create connection profile from stored profile', () => {
|
||||
let savedProfile = storedProfile;
|
||||
let connectionProfile = ConnectionProfile.createFromStoredProfile(savedProfile, capabilitiesService);
|
||||
assert.equal(savedProfile.groupId, connectionProfile.groupId);
|
||||
assert.deepEqual(savedProfile.providerName, connectionProfile.providerName);
|
||||
assert.deepEqual(savedProfile.savePassword, connectionProfile.savePassword);
|
||||
assert.deepEqual(savedProfile.id, connectionProfile.id);
|
||||
assert.strictEqual(savedProfile.groupId, connectionProfile.groupId);
|
||||
assert.deepStrictEqual(savedProfile.providerName, connectionProfile.providerName);
|
||||
assert.deepStrictEqual(savedProfile.savePassword, connectionProfile.savePassword);
|
||||
assert.deepStrictEqual(savedProfile.id, connectionProfile.id);
|
||||
});
|
||||
|
||||
test('createFromStoredProfile should set the id to new guid if not set in stored profile', () => {
|
||||
let savedProfile: IConnectionProfileStore = Object.assign({}, storedProfile, { id: undefined });
|
||||
let connectionProfile = ConnectionProfile.createFromStoredProfile(savedProfile, capabilitiesService);
|
||||
assert.equal(savedProfile.groupId, connectionProfile.groupId);
|
||||
assert.deepEqual(savedProfile.providerName, connectionProfile.providerName);
|
||||
assert.equal(savedProfile.savePassword, connectionProfile.savePassword);
|
||||
assert.notEqual(connectionProfile.id, undefined);
|
||||
assert.equal(savedProfile.id, undefined);
|
||||
assert.strictEqual(savedProfile.groupId, connectionProfile.groupId);
|
||||
assert.deepStrictEqual(savedProfile.providerName, connectionProfile.providerName);
|
||||
assert.strictEqual(savedProfile.savePassword, connectionProfile.savePassword);
|
||||
assert.notStrictEqual(connectionProfile.id, undefined);
|
||||
assert.strictEqual(savedProfile.id, undefined);
|
||||
});
|
||||
|
||||
test('withoutPassword should create a new instance without password', () => {
|
||||
let conn = new ConnectionProfile(capabilitiesService, connectionProfile);
|
||||
assert.notEqual(conn.password, '');
|
||||
assert.notStrictEqual(conn.password, '');
|
||||
let withoutPassword = conn.withoutPassword();
|
||||
assert.equal(withoutPassword.password, '');
|
||||
assert.strictEqual(withoutPassword.password, '');
|
||||
});
|
||||
|
||||
test('unique id should not include password', () => {
|
||||
let conn = new ConnectionProfile(capabilitiesService, connectionProfile);
|
||||
let withoutPassword = conn.withoutPassword();
|
||||
assert.equal(withoutPassword.getOptionsKey(), conn.getOptionsKey());
|
||||
assert.strictEqual(withoutPassword.getOptionsKey(), conn.getOptionsKey());
|
||||
});
|
||||
|
||||
test('cloneWithDatabase should create new profile with new id', () => {
|
||||
let conn = new ConnectionProfile(capabilitiesService, connectionProfile);
|
||||
let newProfile = conn.cloneWithDatabase('new db');
|
||||
assert.notEqual(newProfile.id, conn.id);
|
||||
assert.equal(newProfile.databaseName, 'new db');
|
||||
assert.notStrictEqual(newProfile.id, conn.id);
|
||||
assert.strictEqual(newProfile.databaseName, 'new db');
|
||||
});
|
||||
|
||||
test('an empty connection profile does not cause issues', () => {
|
||||
|
||||
@@ -33,97 +33,97 @@ suite('SQL ConnectionProfileGroup tests', () => {
|
||||
});
|
||||
|
||||
test('Root name should be returned as empty string', () => {
|
||||
assert.equal(root.name, '');
|
||||
assert.strictEqual(root.name, '');
|
||||
});
|
||||
|
||||
test('Fullname should return the group full name correctly', () => {
|
||||
assert.equal(group1Node.fullName, 'G1');
|
||||
assert.equal(group2Node.fullName, 'G2');
|
||||
assert.equal(group11Node.fullName, 'G1/G11');
|
||||
assert.strictEqual(group1Node.fullName, 'G1');
|
||||
assert.strictEqual(group2Node.fullName, 'G2');
|
||||
assert.strictEqual(group11Node.fullName, 'G1/G11');
|
||||
});
|
||||
|
||||
test('getGroupFullNameParts should return a list With ROOT in it given an empty string', () => {
|
||||
let groupFullName: string = '';
|
||||
let expected: string[] = [ConnectionProfileGroup.RootGroupName];
|
||||
let actual = ConnectionProfileGroup.getGroupFullNameParts(groupFullName);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('getGroupFullNameParts should return a list With ROOT in it given null', () => {
|
||||
let groupFullName: string = undefined!;
|
||||
let expected: string[] = [ConnectionProfileGroup.RootGroupName];
|
||||
let actual = ConnectionProfileGroup.getGroupFullNameParts(groupFullName);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('getGroupFullNameParts should return a list With ROOT in it given /', () => {
|
||||
let groupFullName: string = '/';
|
||||
let expected: string[] = [ConnectionProfileGroup.RootGroupName];
|
||||
let actual = ConnectionProfileGroup.getGroupFullNameParts(groupFullName);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('getGroupFullNameParts should add ROOT as first item if not added already and string starts with /', () => {
|
||||
let groupFullName: string = '/Groups/Group1';
|
||||
let expected: string[] = [ConnectionProfileGroup.RootGroupName, 'Groups', 'Group1'];
|
||||
let actual = ConnectionProfileGroup.getGroupFullNameParts(groupFullName);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('getGroupFullNameParts should add ROOT as first item if not added already', () => {
|
||||
let groupFullName: string = 'Groups/Group1';
|
||||
let expected: string[] = [ConnectionProfileGroup.RootGroupName, 'Groups', 'Group1'];
|
||||
let actual = ConnectionProfileGroup.getGroupFullNameParts(groupFullName);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('getGroupFullNameParts should not add ROOT if already added and string starts with /', () => {
|
||||
let groupFullName: string = '/ROOT/Groups/Group1';
|
||||
let expected: string[] = [ConnectionProfileGroup.RootGroupName, 'Groups', 'Group1'];
|
||||
let actual = ConnectionProfileGroup.getGroupFullNameParts(groupFullName);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('getGroupFullNameParts should not add ROOT if already added', () => {
|
||||
let groupFullName: string = 'ROOT/Groups/Group1';
|
||||
let expected: string[] = [ConnectionProfileGroup.RootGroupName, 'Groups', 'Group1'];
|
||||
let actual = ConnectionProfileGroup.getGroupFullNameParts(groupFullName);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('getGroupFullNameParts should not add ROOT if already added and it is not uppercase', () => {
|
||||
let groupFullName: string = 'rOOT/Groups/Group1';
|
||||
let expected: string[] = [ConnectionProfileGroup.RootGroupName, 'Groups', 'Group1'];
|
||||
let actual = ConnectionProfileGroup.getGroupFullNameParts(groupFullName);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('isRoot should return true given empty string', () => {
|
||||
let name: string = '';
|
||||
let expected: boolean = true;
|
||||
let actual = ConnectionProfileGroup.isRoot(name);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('isRoot should return true given null', () => {
|
||||
let name: string = undefined!;
|
||||
let expected: boolean = true;
|
||||
let actual = ConnectionProfileGroup.isRoot(name);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('isRoot should return true given /', () => {
|
||||
let name: string = '/';
|
||||
let expected: boolean = true;
|
||||
let actual = ConnectionProfileGroup.isRoot(name);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('isRoot should return true given root', () => {
|
||||
let name: string = 'root';
|
||||
let expected: boolean = true;
|
||||
let actual = ConnectionProfileGroup.isRoot(name);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('sameGroupName should return true given root', () => {
|
||||
@@ -131,7 +131,7 @@ suite('SQL ConnectionProfileGroup tests', () => {
|
||||
let name2: string = '';
|
||||
let expected: boolean = true;
|
||||
let actual = ConnectionProfileGroup.sameGroupName(name1, name2);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('sameGroupName should return true given same group names', () => {
|
||||
@@ -139,7 +139,7 @@ suite('SQL ConnectionProfileGroup tests', () => {
|
||||
let name2: string = '/Group1';
|
||||
let expected: boolean = true;
|
||||
let actual = ConnectionProfileGroup.sameGroupName(name1, name2);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('sameGroupName should return false given two different groups', () => {
|
||||
@@ -147,15 +147,15 @@ suite('SQL ConnectionProfileGroup tests', () => {
|
||||
let name2: string = '/Group1';
|
||||
let expected: boolean = false;
|
||||
let actual = ConnectionProfileGroup.sameGroupName(name1, name2);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('test behavior when children is set to undefined', () => {
|
||||
emptyGroup.children = undefined;
|
||||
assert(emptyGroup.hasChildren() === false, 'Group should report no children after setting children to undefined');
|
||||
const obj = emptyGroup.toObject();
|
||||
assert.equal(obj.id, emptyGroup.id, 'toObject result has wrong id');
|
||||
assert.equal(obj.name, emptyGroup.name, 'toObject result has wrong name');
|
||||
assert.strictEqual(obj.id, emptyGroup.id, 'toObject result has wrong id');
|
||||
assert.strictEqual(obj.name, emptyGroup.name, 'toObject result has wrong name');
|
||||
assert(emptyGroup.hasValidConnections === true, 'Expected group to have valid connections');
|
||||
const children = emptyGroup.getChildren();
|
||||
assert(children.length === 0, 'Expected group to have 0 children');
|
||||
@@ -165,11 +165,11 @@ suite('SQL ConnectionProfileGroup tests', () => {
|
||||
emptyGroup.connections = undefined;
|
||||
assert(emptyGroup.hasChildren() === false, 'Group should report no children after setting connections to undefined');
|
||||
const obj = emptyGroup.toObject();
|
||||
assert.equal(obj.id, emptyGroup.id, 'toObject result has wrong id');
|
||||
assert.equal(obj.name, emptyGroup.name, 'toObject result has wrong name');
|
||||
assert.strictEqual(obj.id, emptyGroup.id, 'toObject result has wrong id');
|
||||
assert.strictEqual(obj.name, emptyGroup.name, 'toObject result has wrong name');
|
||||
assert(emptyGroup.hasValidConnections === true, 'Expected group to have valid connections');
|
||||
const children = emptyGroup.getChildren();
|
||||
assert.equal(children.length, 0, 'Expected group to have 0 children');
|
||||
assert.strictEqual(children.length, 0, 'Expected group to have 0 children');
|
||||
});
|
||||
|
||||
test('test behavior with 1 child group', () => {
|
||||
@@ -177,8 +177,8 @@ suite('SQL ConnectionProfileGroup tests', () => {
|
||||
assert(emptyGroup.hasChildren() === true, 'Group should have children if 1 child group is added');
|
||||
assert(emptyGroup.hasValidConnections === true, 'Expected group to have valid connections');
|
||||
const children = emptyGroup.getChildren();
|
||||
assert.equal(children.length, 1, 'Expected group to have 1 child');
|
||||
assert.equal(children[0].id, group1Node.id, 'Expected group child to be group1Node');
|
||||
assert.strictEqual(children.length, 1, 'Expected group to have 1 child');
|
||||
assert.strictEqual(children[0].id, group1Node.id, 'Expected group child to be group1Node');
|
||||
});
|
||||
|
||||
test('test behavior with 1 child connection', () => {
|
||||
@@ -186,8 +186,8 @@ suite('SQL ConnectionProfileGroup tests', () => {
|
||||
assert(emptyGroup.hasChildren(), 'Group should have children if 1 child group is added');
|
||||
assert(emptyGroup.hasValidConnections === false, 'Expected group not to have valid connections');
|
||||
const children = emptyGroup.getChildren();
|
||||
assert.equal(children.length, 1, 'Expected group to have 1 child');
|
||||
assert.equal(children[0].id, connectionProfile.id, 'Expected group child to be connectionProfile');
|
||||
assert.strictEqual(children.length, 1, 'Expected group to have 1 child');
|
||||
assert.strictEqual(children[0].id, connectionProfile.id, 'Expected group child to be connectionProfile');
|
||||
});
|
||||
|
||||
test('adding undefined groups does nothing', () => {
|
||||
@@ -197,8 +197,8 @@ suite('SQL ConnectionProfileGroup tests', () => {
|
||||
emptyGroup.addGroups([group1Node]);
|
||||
emptyGroup.addGroups(undefined);
|
||||
const children = emptyGroup.getChildren();
|
||||
assert.equal(children.length, 1, 'Expected group to have 1 child still');
|
||||
assert.equal(children[0].id, group1Node.id, 'Expected group child to be group1Node');
|
||||
assert.strictEqual(children.length, 1, 'Expected group to have 1 child still');
|
||||
assert.strictEqual(children[0].id, group1Node.id, 'Expected group child to be group1Node');
|
||||
});
|
||||
|
||||
test('adding undefined connections does nothing', () => {
|
||||
@@ -208,7 +208,7 @@ suite('SQL ConnectionProfileGroup tests', () => {
|
||||
emptyGroup.addConnections([connectionProfile]);
|
||||
emptyGroup.addConnections(undefined);
|
||||
const children = emptyGroup.getChildren();
|
||||
assert.equal(children.length, 1, 'Expected group to have 1 child still');
|
||||
assert.equal(children[0].id, connectionProfile.id, 'Expected group child to be connectionProfile');
|
||||
assert.strictEqual(children.length, 1, 'Expected group to have 1 child still');
|
||||
assert.strictEqual(children[0].id, connectionProfile.id, 'Expected group child to be connectionProfile');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -159,14 +159,14 @@ suite('ConnectionStore', () => {
|
||||
await connectionStore.addRecentConnection(connectionProfile);
|
||||
const current = connectionStore.getRecentlyUsedConnections();
|
||||
if (i >= maxRecent) {
|
||||
assert.equal(current.length, maxRecent, `expect only top ${maxRecent} creds to be saved`);
|
||||
assert.strictEqual(current.length, maxRecent, `expect only top ${maxRecent} creds to be saved`);
|
||||
} else {
|
||||
assert.equal(current.length, i + 1, `expect all credentials to be saved ${current.length}|${i + 1} `);
|
||||
assert.strictEqual(current.length, i + 1, `expect all credentials to be saved ${current.length}|${i + 1} `);
|
||||
}
|
||||
assert.equal(current[0].serverName, cred.serverName, 'Expect most recently saved item to be first in list');
|
||||
assert.strictEqual(current[0].serverName, cred.serverName, 'Expect most recently saved item to be first in list');
|
||||
assert.ok(!current[0].password);
|
||||
}
|
||||
assert.equal(credentialsService.credentials.size, numCreds);
|
||||
assert.strictEqual(credentialsService.credentials.size, numCreds);
|
||||
});
|
||||
|
||||
test('getRecentlyUsedConnections should return connection for given provider', () => {
|
||||
@@ -196,8 +196,8 @@ suite('ConnectionStore', () => {
|
||||
await connectionStore.addRecentConnection(connectionProfile);
|
||||
await connectionStore.addRecentConnection(connectionProfile);
|
||||
const current = connectionStore.getRecentlyUsedConnections();
|
||||
assert.equal(current.length, 2, 'expect 2 unique credentials to have been added');
|
||||
assert.equal(current[0].serverName, cred.serverName, 'Expect most recently saved item to be first in list');
|
||||
assert.strictEqual(current.length, 2, 'expect 2 unique credentials to have been added');
|
||||
assert.strictEqual(current[0].serverName, cred.serverName, 'Expect most recently saved item to be first in list');
|
||||
assert.ok(!current[0].password);
|
||||
});
|
||||
|
||||
@@ -231,7 +231,7 @@ suite('ConnectionStore', () => {
|
||||
|
||||
let current = connectionStore.getRecentlyUsedConnections();
|
||||
// Then verify that since its password based we save the password
|
||||
assert.equal(credentialsService.credentials.size, 1);
|
||||
assert.strictEqual(credentialsService.credentials.size, 1);
|
||||
assert.strictEqual(recentCredential!.password, defaultNamedProfile.password);
|
||||
assert.ok(recentCredential!.credentialId.indexOf('Profile') > -1, 'Expect credential to be marked as an Profile cred');
|
||||
assert.ok(!current[0].password);
|
||||
@@ -240,24 +240,24 @@ suite('ConnectionStore', () => {
|
||||
await connectionStore.addRecentConnection(integratedCredConnectionProfile);
|
||||
current = connectionStore.getRecentlyUsedConnections();
|
||||
// then expect not to have credential store called, but MRU count upped to 2
|
||||
assert.equal(credentialsService.credentials.size, 1);
|
||||
assert.equal(current.length, 2);
|
||||
assert.strictEqual(credentialsService.credentials.size, 1);
|
||||
assert.strictEqual(current.length, 2);
|
||||
// When add connection without password
|
||||
const noPwdCredConnectionProfile = new ConnectionProfile(capabilitiesService, noPwdCred);
|
||||
await connectionStore.addRecentConnection(noPwdCredConnectionProfile);
|
||||
current = connectionStore.getRecentlyUsedConnections();
|
||||
// then expect not to have credential store called, but MRU count upped to 3
|
||||
assert.equal(current.length, 3);
|
||||
assert.equal(credentialsService.credentials.size, 1);
|
||||
assert.strictEqual(current.length, 3);
|
||||
assert.strictEqual(credentialsService.credentials.size, 1);
|
||||
});
|
||||
|
||||
test('fixupConnectionCredentials should fix blank connection profile', () => {
|
||||
let blankConnectionProfile = new ConnectionProfile(capabilitiesService, '');
|
||||
let resultProfile = fixupConnectionCredentials(blankConnectionProfile);
|
||||
assert.equal(resultProfile.serverName, '');
|
||||
assert.equal(resultProfile.databaseName, '');
|
||||
assert.equal(resultProfile.userName, '');
|
||||
assert.equal(resultProfile.password, '');
|
||||
assert.strictEqual(resultProfile.serverName, '');
|
||||
assert.strictEqual(resultProfile.databaseName, '');
|
||||
assert.strictEqual(resultProfile.userName, '');
|
||||
assert.strictEqual(resultProfile.password, '');
|
||||
});
|
||||
|
||||
test('can clear connections list', async () => {
|
||||
@@ -270,10 +270,10 @@ suite('ConnectionStore', () => {
|
||||
|
||||
await connectionStore.addRecentConnection(defaultNamedProfile);
|
||||
let result = connectionStore.getRecentlyUsedConnections();
|
||||
assert.equal(result.length, 1);
|
||||
assert.strictEqual(result.length, 1);
|
||||
connectionStore.clearRecentlyUsed();
|
||||
result = connectionStore.getRecentlyUsedConnections();
|
||||
assert.equal(result.length, 0);
|
||||
assert.strictEqual(result.length, 0);
|
||||
// Then test is complete
|
||||
});
|
||||
|
||||
@@ -340,7 +340,7 @@ suite('ConnectionStore', () => {
|
||||
|
||||
const profile = await connectionStore.saveProfile(connectionProfile);
|
||||
// add connection should be called with a profile without password
|
||||
assert.equal(profile.password, password, 'The returned profile should still keep the password');
|
||||
assert.strictEqual(profile.password, password, 'The returned profile should still keep the password');
|
||||
assert.ok(!!profile.groupId, 'Group id should be set in the profile');
|
||||
});
|
||||
|
||||
@@ -352,7 +352,7 @@ suite('ConnectionStore', () => {
|
||||
const connectionStore = new ConnectionStore(storageService, configurationService,
|
||||
credentialsService, capabilitiesService);
|
||||
const group = connectionStore.getGroupFromId('invalidId');
|
||||
assert.equal(group, undefined, 'Returned group was not undefined when there was no group with the given ID');
|
||||
assert.strictEqual(group, undefined, 'Returned group was not undefined when there was no group with the given ID');
|
||||
});
|
||||
|
||||
test('getGroupFromId returns the group that has the given ID', () => {
|
||||
@@ -386,11 +386,11 @@ suite('ConnectionStore', () => {
|
||||
|
||||
// If I look up the parent group using its ID, then I get back the correct group
|
||||
let actualGroup = connectionStore.getGroupFromId(parentGroupId)!;
|
||||
assert.equal(actualGroup.id, parentGroupId, 'Did not get the parent group when looking it up with its ID');
|
||||
assert.strictEqual(actualGroup.id, parentGroupId, 'Did not get the parent group when looking it up with its ID');
|
||||
|
||||
// If I look up the child group using its ID, then I get back the correct group
|
||||
actualGroup = connectionStore.getGroupFromId(childGroupId)!;
|
||||
assert.equal(actualGroup.id, childGroupId, 'Did not get the child group when looking it up with its ID');
|
||||
assert.strictEqual(actualGroup.id, childGroupId, 'Did not get the child group when looking it up with its ID');
|
||||
});
|
||||
|
||||
test('getProfileWithoutPassword can return the profile without credentials in the password property or options dictionary', () => {
|
||||
@@ -408,7 +408,7 @@ suite('ConnectionStore', () => {
|
||||
expectedProfile.options['password'] = '';
|
||||
expectedProfile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, expectedProfile).toIConnectionProfile();
|
||||
let profileWithoutCredentials = connectionStore.getProfileWithoutPassword(profile);
|
||||
assert.deepEqual(profileWithoutCredentials.toIConnectionProfile(), expectedProfile);
|
||||
assert.deepStrictEqual(profileWithoutCredentials.toIConnectionProfile(), expectedProfile);
|
||||
});
|
||||
|
||||
test('addPassword gets the password from the credentials service', async () => {
|
||||
@@ -428,7 +428,7 @@ suite('ConnectionStore', () => {
|
||||
|
||||
const passwordProfile = (await connectionStore.addSavedPassword(profile)).profile;
|
||||
|
||||
assert.equal(passwordProfile.password, password);
|
||||
assert.strictEqual(passwordProfile.password, password);
|
||||
});
|
||||
|
||||
test('getConnectionProfileGroups', async () => {
|
||||
@@ -481,7 +481,7 @@ suite('ConnectionStore', () => {
|
||||
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
|
||||
await connectionStore.addRecentConnection(connectionProfile);
|
||||
const current = connectionStore.getRecentlyUsedConnections();
|
||||
assert.equal(current.length, i + 1);
|
||||
assert.strictEqual(current.length, i + 1);
|
||||
}
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
@@ -489,7 +489,7 @@ suite('ConnectionStore', () => {
|
||||
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
|
||||
connectionStore.removeRecentConnection(connectionProfile);
|
||||
const current = connectionStore.getRecentlyUsedConnections();
|
||||
assert.equal(current.length, 4 - i);
|
||||
assert.strictEqual(current.length, 4 - i);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -533,6 +533,6 @@ suite('ConnectionStore', () => {
|
||||
|
||||
const connections = connectionStore.getRecentlyUsedConnections();
|
||||
|
||||
assert.equal(connections[0].groupFullName, parentGroupName);
|
||||
assert.strictEqual(connections[0].groupFullName, parentGroupName);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -132,62 +132,62 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
||||
|
||||
test('constructor should accept undefined parameters', () => {
|
||||
let conn = new ProviderConnectionInfo(undefined!, undefined!);
|
||||
assert.equal(conn.serverName, undefined);
|
||||
assert.strictEqual(conn.serverName, undefined);
|
||||
});
|
||||
|
||||
test('set properties should set the values correctly', () => {
|
||||
let conn = new ProviderConnectionInfo(capabilitiesService, mssqlProviderName);
|
||||
assert.equal(conn.serverName, undefined);
|
||||
assert.strictEqual(conn.serverName, undefined);
|
||||
conn.connectionName = connectionProfile.connectionName!;
|
||||
conn.serverName = connectionProfile.serverName;
|
||||
conn.databaseName = connectionProfile.databaseName!;
|
||||
conn.authenticationType = connectionProfile.authenticationType;
|
||||
conn.password = connectionProfile.password;
|
||||
conn.userName = connectionProfile.userName;
|
||||
assert.equal(conn.connectionName, connectionProfile.connectionName);
|
||||
assert.equal(conn.serverName, connectionProfile.serverName);
|
||||
assert.equal(conn.databaseName, connectionProfile.databaseName);
|
||||
assert.equal(conn.authenticationType, connectionProfile.authenticationType);
|
||||
assert.equal(conn.password, connectionProfile.password);
|
||||
assert.equal(conn.userName, connectionProfile.userName);
|
||||
assert.strictEqual(conn.connectionName, connectionProfile.connectionName);
|
||||
assert.strictEqual(conn.serverName, connectionProfile.serverName);
|
||||
assert.strictEqual(conn.databaseName, connectionProfile.databaseName);
|
||||
assert.strictEqual(conn.authenticationType, connectionProfile.authenticationType);
|
||||
assert.strictEqual(conn.password, connectionProfile.password);
|
||||
assert.strictEqual(conn.userName, connectionProfile.userName);
|
||||
});
|
||||
|
||||
test('set properties should store the values in the options', () => {
|
||||
let conn = new ProviderConnectionInfo(capabilitiesService, mssqlProviderName);
|
||||
assert.equal(conn.serverName, undefined);
|
||||
assert.strictEqual(conn.serverName, undefined);
|
||||
conn.serverName = connectionProfile.serverName;
|
||||
conn.databaseName = connectionProfile.databaseName!;
|
||||
conn.authenticationType = connectionProfile.authenticationType;
|
||||
conn.password = connectionProfile.password;
|
||||
conn.userName = connectionProfile.userName;
|
||||
assert.equal(conn.getOptionValue('serverName'), connectionProfile.serverName);
|
||||
assert.equal(conn.getOptionValue('databaseName'), connectionProfile.databaseName);
|
||||
assert.equal(conn.getOptionValue('authenticationType'), connectionProfile.authenticationType);
|
||||
assert.equal(conn.getOptionValue('password'), connectionProfile.password);
|
||||
assert.equal(conn.getOptionValue('userName'), connectionProfile.userName);
|
||||
assert.strictEqual(conn.getOptionValue('serverName'), connectionProfile.serverName);
|
||||
assert.strictEqual(conn.getOptionValue('databaseName'), connectionProfile.databaseName);
|
||||
assert.strictEqual(conn.getOptionValue('authenticationType'), connectionProfile.authenticationType);
|
||||
assert.strictEqual(conn.getOptionValue('password'), connectionProfile.password);
|
||||
assert.strictEqual(conn.getOptionValue('userName'), connectionProfile.userName);
|
||||
});
|
||||
|
||||
test('constructor should initialize the options given a valid model', () => {
|
||||
let conn = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
|
||||
|
||||
assert.equal(conn.connectionName, connectionProfile.connectionName);
|
||||
assert.equal(conn.serverName, connectionProfile.serverName);
|
||||
assert.equal(conn.databaseName, connectionProfile.databaseName);
|
||||
assert.equal(conn.authenticationType, connectionProfile.authenticationType);
|
||||
assert.equal(conn.password, connectionProfile.password);
|
||||
assert.equal(conn.userName, connectionProfile.userName);
|
||||
assert.strictEqual(conn.connectionName, connectionProfile.connectionName);
|
||||
assert.strictEqual(conn.serverName, connectionProfile.serverName);
|
||||
assert.strictEqual(conn.databaseName, connectionProfile.databaseName);
|
||||
assert.strictEqual(conn.authenticationType, connectionProfile.authenticationType);
|
||||
assert.strictEqual(conn.password, connectionProfile.password);
|
||||
assert.strictEqual(conn.userName, connectionProfile.userName);
|
||||
});
|
||||
|
||||
test('clone should create a new instance that equals the old one', () => {
|
||||
let conn = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
|
||||
|
||||
let conn2 = conn.clone();
|
||||
assert.equal(conn.connectionName, conn2.connectionName);
|
||||
assert.equal(conn.serverName, conn2.serverName);
|
||||
assert.equal(conn.databaseName, conn2.databaseName);
|
||||
assert.equal(conn.authenticationType, conn2.authenticationType);
|
||||
assert.equal(conn.password, conn2.password);
|
||||
assert.equal(conn.userName, conn2.userName);
|
||||
assert.strictEqual(conn.connectionName, conn2.connectionName);
|
||||
assert.strictEqual(conn.serverName, conn2.serverName);
|
||||
assert.strictEqual(conn.databaseName, conn2.databaseName);
|
||||
assert.strictEqual(conn.authenticationType, conn2.authenticationType);
|
||||
assert.strictEqual(conn.password, conn2.password);
|
||||
assert.strictEqual(conn.userName, conn2.userName);
|
||||
});
|
||||
|
||||
test('Changing the cloned object should not change the original one', () => {
|
||||
@@ -195,7 +195,7 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
||||
|
||||
let conn2 = conn.clone();
|
||||
conn2.serverName = conn.serverName + '1';
|
||||
assert.notEqual(conn.serverName, conn2.serverName);
|
||||
assert.notStrictEqual(conn.serverName, conn2.serverName);
|
||||
});
|
||||
|
||||
test('constructor should initialize the options given a valid model with options', () => {
|
||||
@@ -204,44 +204,44 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
||||
let conn2 = Object.assign({}, connectionProfile, { options: options });
|
||||
let conn = new ProviderConnectionInfo(capabilitiesService, conn2);
|
||||
|
||||
assert.equal(conn.connectionName, conn2.connectionName);
|
||||
assert.equal(conn.serverName, conn2.serverName);
|
||||
assert.equal(conn.databaseName, conn2.databaseName);
|
||||
assert.equal(conn.authenticationType, conn2.authenticationType);
|
||||
assert.equal(conn.password, conn2.password);
|
||||
assert.equal(conn.userName, conn2.userName);
|
||||
assert.equal(conn.options['encrypt'], 'test value');
|
||||
assert.strictEqual(conn.connectionName, conn2.connectionName);
|
||||
assert.strictEqual(conn.serverName, conn2.serverName);
|
||||
assert.strictEqual(conn.databaseName, conn2.databaseName);
|
||||
assert.strictEqual(conn.authenticationType, conn2.authenticationType);
|
||||
assert.strictEqual(conn.password, conn2.password);
|
||||
assert.strictEqual(conn.userName, conn2.userName);
|
||||
assert.strictEqual(conn.options['encrypt'], 'test value');
|
||||
});
|
||||
|
||||
test('getOptionsKey should create a valid unique id', () => {
|
||||
let conn = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
|
||||
let expectedId = 'providerName:MSSQL|authenticationType:|databaseName:database|serverName:new server|userName:user';
|
||||
let id = conn.getOptionsKey();
|
||||
assert.equal(id, expectedId);
|
||||
assert.strictEqual(id, expectedId);
|
||||
});
|
||||
|
||||
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' }));
|
||||
|
||||
assert.notEqual(conn.getOptionsKey(), conn2.getOptionsKey());
|
||||
assert.notStrictEqual(conn.getOptionsKey(), conn2.getOptionsKey());
|
||||
});
|
||||
|
||||
test('titleParts should return server, database and auth type as first items', () => {
|
||||
let conn = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
|
||||
let titleParts = conn.titleParts;
|
||||
assert.equal(titleParts.length, 4);
|
||||
assert.equal(titleParts[0], connectionProfile.serverName);
|
||||
assert.equal(titleParts[1], connectionProfile.databaseName);
|
||||
assert.equal(titleParts[2], connectionProfile.authenticationType);
|
||||
assert.equal(titleParts[3], connectionProfile.userName);
|
||||
assert.strictEqual(titleParts.length, 4);
|
||||
assert.strictEqual(titleParts[0], connectionProfile.serverName);
|
||||
assert.strictEqual(titleParts[1], connectionProfile.databaseName);
|
||||
assert.strictEqual(titleParts[2], connectionProfile.authenticationType);
|
||||
assert.strictEqual(titleParts[3], connectionProfile.userName);
|
||||
});
|
||||
|
||||
test('getProviderFromOptionsKey should return the provider name from the options key successfully', () => {
|
||||
let optionsKey = `providerName:${mssqlProviderName}|authenticationType:|databaseName:database|serverName:new server|userName:user`;
|
||||
let actual = ProviderConnectionInfo.getProviderFromOptionsKey(optionsKey);
|
||||
|
||||
assert.equal(mssqlProviderName, actual);
|
||||
assert.strictEqual(mssqlProviderName, actual);
|
||||
});
|
||||
|
||||
test('getProviderFromOptionsKey should return empty string give null', () => {
|
||||
@@ -249,7 +249,7 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
||||
let expectedProviderId: string = '';
|
||||
let actual = ProviderConnectionInfo.getProviderFromOptionsKey(optionsKey);
|
||||
|
||||
assert.equal(expectedProviderId, actual);
|
||||
assert.strictEqual(expectedProviderId, actual);
|
||||
});
|
||||
|
||||
test('getProviderFromOptionsKey should return empty string give key without provider name', () => {
|
||||
@@ -257,6 +257,6 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
||||
let expectedProviderId: string = '';
|
||||
let actual = ProviderConnectionInfo.getProviderFromOptionsKey(optionsKey);
|
||||
|
||||
assert.equal(expectedProviderId, actual);
|
||||
assert.strictEqual(expectedProviderId, actual);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user