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
6 changes: 5 additions & 1 deletion packages/cli-repl/src/mongosh-repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ class MongoshNodeRepl implements EvaluationListener {
internalState.setEvaluationListener(this);
await internalState.fetchConnectionInfo();

const mongodVersion = internalState.connectionInfo.buildInfo?.version;
let mongodVersion = internalState.connectionInfo.buildInfo?.version;
const apiVersion = serviceProvider.getRawClient()?.serverApi?.version;
if (apiVersion) {
mongodVersion = (mongodVersion ? mongodVersion + ' ' : '') + `(API Version ${apiVersion})`;
}
await this.greet(mongodVersion);
await this.printStartupLog(internalState);

Expand Down
16 changes: 16 additions & 0 deletions packages/cli-repl/test/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,22 @@ describe('e2e', function() {
`${await testServer.connectionString()}/${dbName}`, '--apiVersion', '1'
] });
await shell.waitForPrompt();
shell.assertContainsOutput('(API Version 1)');
expect(await shell.executeLine('db.coll.find().toArray()'))
.to.include('[]');
shell.assertNoErrors();
});

it('can specify an API version and strict mode', async function() {
// Disable this until https://jira.mongodb.org/browse/NODE-3183
// is done because the server has started requiring hello instead of
// isMaster.
return this.skip();
const shell = TestShell.start({ args: [
`${await testServer.connectionString()}/${dbName}`, '--apiVersion', '1', '--apiStrict', '--apiDeprecationErrors'
] });
await shell.waitForPrompt();
shell.assertContainsOutput('(API Version 1)');
expect(await shell.executeLine('db.coll.find().toArray()'))
.to.include('[]');
shell.assertNoErrors();
Expand Down