Skip to content

Commit

Permalink
STREAMS-576: do not show MDB version for SPI
Browse files Browse the repository at this point in the history
  • Loading branch information
shaketbaby committed Sep 20, 2023
1 parent e099bc0 commit 911035c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
24 changes: 24 additions & 0 deletions packages/cli-repl/src/mongosh-repl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1309,4 +1309,28 @@ describe('MongoshNodeRepl', function () {
expect(output).to.not.match(/Using MongoDB/);
});
});

context('with is_stream: true', function () {
beforeEach(async function () {
sp.getConnectionInfo.resolves({
extraInfo: {
uri: 'mongodb://localhost:27017/test',
is_localhost: true,
is_stream: true,
},
buildInfo: {
version: '4.4.1',
},
});
mongoshReplOptions.shellCliOptions = {
nodb: false,
};
mongoshRepl = new MongoshNodeRepl(mongoshReplOptions);
await mongoshRepl.initialize(serviceProvider);
});

it('shows Atlas Stream Processing', function () {
expect(output).to.match(/Using MongoDB:\t\tAtlas Stream Processing/);
});
});
});
21 changes: 13 additions & 8 deletions packages/cli-repl/src/mongosh-repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,17 @@ class MongoshNodeRepl implements EvaluationListener {
instanceState.setEvaluationListener(this);
await instanceState.fetchConnectionInfo();

let mongodVersion = instanceState.connectionInfo.buildInfo?.version;
const apiVersion = serviceProvider.getRawClient()?.serverApi?.version;
if (apiVersion) {
mongodVersion =
(mongodVersion ? mongodVersion + ' ' : '') +
`(API Version ${apiVersion})`;
const { buildInfo, extraInfo } = instanceState.connectionInfo;
let mongodVersion = extraInfo?.is_stream
? 'Atlas Stream Processing'
: buildInfo?.version;
if (!extraInfo?.is_stream) {
const apiVersion = serviceProvider.getRawClient()?.serverApi?.version;
if (apiVersion) {
mongodVersion =
(mongodVersion ? mongodVersion + ' ' : '') +
`(API Version ${apiVersion})`;
}
}
await this.greet(mongodVersion, moreRecentMongoshVersion);
await this.printBasicConnectivityWarning(instanceState);
Expand Down Expand Up @@ -456,15 +461,15 @@ class MongoshNodeRepl implements EvaluationListener {
* The greeting for the shell, showing server and shell version.
*/
async greet(
mongodVersion: string,
mongodVersion?: string,
moreRecentMongoshVersion?: string | null
): Promise<void> {
if (this.shellCliOptions.quiet) {
return;
}
const { version } = require('../package.json');
let text = '';
if (!this.shellCliOptions.nodb) {
if (mongodVersion && !this.shellCliOptions.nodb) {
text += `Using MongoDB:\t\t${mongodVersion}\n`;
}
text += `${this.clr(
Expand Down

0 comments on commit 911035c

Please sign in to comment.