Skip to content

Commit 54ceabf

Browse files
authored
MONGOSH-268: Fix autocompletion in compass-shell (#251)
1 parent 2916a10 commit 54ceabf

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

packages/service-provider-core/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"scripts": {
1515
"compile-ts": "tsc -p tsconfig.json",
1616
"prepublish": "npm run compile-ts",
17+
"test": "mocha -r \"../../scripts/import-expansions.js\" --timeout 60000 --colors -r ts-node/register \"./src/**/*.spec.ts\"",
18+
"test-ci": "mocha -r \"../../scripts/import-expansions.js\" --timeout 60000 -r ts-node/register \"./src/**/*.spec.ts\"",
1719
"lint": "eslint \"**/*.{js,ts,tsx}\"",
1820
"check": "npm run lint"
1921
},

packages/service-provider-core/src/connect-info.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,29 @@ describe('getConnectInfo', function() {
122122
CMD_LINE_OPTS,
123123
TOPOLOGY_NO_CREDENTIALS)).to.deep.equal(output);
124124
});
125+
126+
it('reports correct information when an empty uri is passed', function() {
127+
const output = {
128+
is_atlas: false,
129+
is_localhost: false,
130+
server_version: '3.2.0-rc2',
131+
mongosh_version: '0.0.6',
132+
is_enterprise: true,
133+
auth_type: 'LDAP',
134+
is_data_lake: false,
135+
dl_version: null,
136+
is_genuine: true,
137+
non_genuine_server_name: 'mongodb',
138+
server_arch: 'x86_64',
139+
node_version: process.version,
140+
server_os: 'osx',
141+
uri: ''
142+
};
143+
expect(getConnectInfo(
144+
'',
145+
'0.0.6',
146+
BUILD_INFO,
147+
CMD_LINE_OPTS,
148+
TOPOLOGY_WITH_CREDENTIALS)).to.deep.equal(output);
149+
});
125150
});

packages/service-provider-server/src/cli-service-provider.integration.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,36 @@ describe('CliServiceProvider [integration]', function() {
4545
});
4646
});
4747

48+
describe('.getConnectionInfo', () => {
49+
context('when a uri has been passed', () => {
50+
it('returns the connection\'s info', async() => {
51+
const instance = new CliServiceProvider(client, connectionString);
52+
const connectionInfo = await instance.getConnectionInfo();
53+
54+
expect(Object.keys(connectionInfo)).to.deep.equal([
55+
'buildInfo',
56+
'topology',
57+
'extraInfo'
58+
]);
59+
expect(connectionInfo.buildInfo.version.length > 1);
60+
});
61+
});
62+
63+
context('when the optional uri has not been passed', () => {
64+
it('returns the connection\'s info', async() => {
65+
const instance = new CliServiceProvider(client);
66+
const connectionInfo = await instance.getConnectionInfo();
67+
68+
expect(Object.keys(connectionInfo)).to.deep.equal([
69+
'buildInfo',
70+
'topology',
71+
'extraInfo'
72+
]);
73+
expect(connectionInfo.buildInfo.version.length > 1);
74+
});
75+
});
76+
});
77+
4878
describe('#aggregate', () => {
4979
context('when running against a collection', () => {
5080
let result;

packages/service-provider-server/src/cli-service-provider.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class CliServiceProvider implements ServiceProvider {
6969
}
7070

7171
private readonly mongoClient: MongoClient;
72-
private readonly uri: string;
72+
private readonly uri?: string;
7373

7474
/**
7575
* Instantiate a new CliServiceProvider with the Node driver's connected
@@ -112,13 +112,15 @@ class CliServiceProvider implements ServiceProvider {
112112
// eslint-disable-next-line no-empty
113113
} catch (e) {
114114
}
115+
115116
const connectInfo = getConnectInfo(
116-
this.uri,
117+
this.uri ? this.uri : '',
117118
version,
118119
buildInfo,
119120
cmdLineOpts,
120121
topology
121122
);
123+
122124
return {
123125
buildInfo: buildInfo,
124126
topology: topology,

0 commit comments

Comments
 (0)