Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/connectionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ export default class ConnectionController {
return reject(new Error(`Unable to connect: ${error}`));
}

// Override the default connection `appname`.
newConnectionModel.appname = `${name} ${version}`;

this.connect(newConnection.id, newConnectionModel).then(
(connectSuccess) => {
if (!connectSuccess) {
Expand Down Expand Up @@ -233,6 +230,9 @@ export default class ConnectionController {
this._statusView.showMessage('Connecting to MongoDB...');

return new Promise<boolean>((resolve, reject) => {
// Override the default connection `appname`.
connectionModel.appname = `${name} ${version}`;

const newDataService: DataServiceType = new DataService(connectionModel);
newDataService.connect((err: Error | undefined) => {
this._statusView.hideMessage();
Expand Down Expand Up @@ -430,13 +430,13 @@ export default class ConnectionController {
const connectionNameToRemove:
| string
| undefined = await vscode.window.showQuickPick(
connectionIds.map(
(id, index) => `${index + 1}: ${this._savedConnections[id].name}`
),
{
placeHolder: 'Choose a connection to remove...'
}
);
connectionIds.map(
(id, index) => `${index + 1}: ${this._savedConnections[id].name}`
),
{
placeHolder: 'Choose a connection to remove...'
}
);

if (!connectionNameToRemove) {
return Promise.resolve(false);
Expand Down
28 changes: 15 additions & 13 deletions src/test/suite/connectionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ suite('Connection Controller Test Suite', () => {
);
const dataService = testConnectionController.getActiveDataService();
assert(dataService !== null);
assert(testConnectionController._activeConnectionModel?.appname.startsWith('mongodb-vscode'));
assert(testConnectionController.isCurrentlyConnected());
})
.then(done, done);
Expand Down Expand Up @@ -477,7 +478,7 @@ suite('Connection Controller Test Suite', () => {
assert(
Object.keys(connections).length === 4,
`Expected 4 connection configurations found ${
Object.keys(connections).length
Object.keys(connections).length
}`
);
assert(
Expand All @@ -486,7 +487,7 @@ suite('Connection Controller Test Suite', () => {
);
assert(
Object.keys(connections).includes('testWorkspaceConnectionModel2') ===
true,
true,
"Expected connection configurations to include 'testWorkspaceConnectionModel2'"
);
assert(
Expand All @@ -495,7 +496,7 @@ suite('Connection Controller Test Suite', () => {
);
assert(
connections.testGlobalConnectionModel2.driverUrl ===
'testGlobalConnectionModel2DriverUrl',
'testGlobalConnectionModel2DriverUrl',
"Expected loaded connection to include driver url 'testGlobalConnectionModel2DriverUrl'"
);
});
Expand Down Expand Up @@ -525,7 +526,7 @@ suite('Connection Controller Test Suite', () => {
assert(
Object.keys(globalStoreConnections).length === 1,
`Expected global store connections to have 1 connection found ${
Object.keys(globalStoreConnections).length
Object.keys(globalStoreConnections).length
}`
);
const id = Object.keys(globalStoreConnections)[0];
Expand Down Expand Up @@ -573,7 +574,7 @@ suite('Connection Controller Test Suite', () => {
assert(
Object.keys(workspaceStoreConnections).length === 1,
`Expected workspace store connections to have 1 connection found ${
Object.keys(workspaceStoreConnections).length
Object.keys(workspaceStoreConnections).length
}`
);
const id = Object.keys(workspaceStoreConnections)[0];
Expand Down Expand Up @@ -619,7 +620,7 @@ suite('Connection Controller Test Suite', () => {
assert(
Object.keys(workspaceStoreConnections).length === 1,
`Expected workspace store connections to have 1 connection found ${
Object.keys(workspaceStoreConnections).length
Object.keys(workspaceStoreConnections).length
}`
);

Expand All @@ -635,7 +636,7 @@ suite('Connection Controller Test Suite', () => {
assert(
testConnectionController.getSavedConnections().length === 1,
`Expected 1 connection config, found ${
testConnectionController.getSavedConnections().length
testConnectionController.getSavedConnections().length
}.`
);
const id = testConnectionController.getSavedConnections()[0].id;
Expand All @@ -655,6 +656,7 @@ suite('Connection Controller Test Suite', () => {
name === 'localhost:27018',
`Expected the active connection name to be 'localhost:27018', found ${name}.`
);
assert(testConnectionController._activeConnectionModel?.appname.startsWith('mongodb-vscode'));
})
.then(done, done);
});
Expand Down Expand Up @@ -778,7 +780,7 @@ suite('Connection Controller Test Suite', () => {
assert(
Object.keys(workspaceStoreConnections).length === 1,
`Expected workspace store connections to have 1 connection found ${
Object.keys(workspaceStoreConnections).length
Object.keys(workspaceStoreConnections).length
}`
);

Expand All @@ -793,7 +795,7 @@ suite('Connection Controller Test Suite', () => {
assert(
Object.keys(postWorkspaceStoreConnections).length === 0,
`Expected workspace store connections to have 0 connections found ${
Object.keys(postWorkspaceStoreConnections).length
Object.keys(postWorkspaceStoreConnections).length
}`
);
})
Expand Down Expand Up @@ -827,7 +829,7 @@ suite('Connection Controller Test Suite', () => {
assert(
Object.keys(globalStoreConnections).length === 1,
`Expected workspace store connections to have 1 connection found ${
Object.keys(globalStoreConnections).length
Object.keys(globalStoreConnections).length
}`
);

Expand All @@ -841,7 +843,7 @@ suite('Connection Controller Test Suite', () => {
assert(
Object.keys(postGlobalStoreConnections).length === 0,
`Expected global store connections to have 0 connections found ${
Object.keys(postGlobalStoreConnections).length
Object.keys(postGlobalStoreConnections).length
}`
);
});
Expand Down Expand Up @@ -877,7 +879,7 @@ suite('Connection Controller Test Suite', () => {
assert(
Object.keys(workspaceStoreConnections).length === 1,
`Expected workspace store connections to have 1 connection found ${
Object.keys(workspaceStoreConnections).length
Object.keys(workspaceStoreConnections).length
}`
);
const connectionId =
Expand Down Expand Up @@ -912,7 +914,7 @@ suite('Connection Controller Test Suite', () => {
testConnectionController.getSavedConnections()
.length === 1,
`Expected 1 connection config, found ${
testConnectionController.getSavedConnections().length
testConnectionController.getSavedConnections().length
}.`
);
const id = testConnectionController.getSavedConnections()[0]
Expand Down