diff --git a/packages/shell-api/src/integration.spec.ts b/packages/shell-api/src/integration.spec.ts index 7c57043c9..bb8b8c2e2 100644 --- a/packages/shell-api/src/integration.spec.ts +++ b/packages/shell-api/src/integration.spec.ts @@ -1303,7 +1303,9 @@ describe('Shell API (integration)', function () { }); }); - describe('validate', function () { + describe('validate [standalone mode]', function () { + // other options are tested in the ReplicaSet suite because they are not available + // in standalone mode skipIfApiStrict(); skipIfServerVersion(testServer, '< 5.0'); @@ -1322,21 +1324,6 @@ describe('Shell API (integration)', function () { (await collection.validate({ full: true, repair: true })).valid ).to.equal(true); }); - - it('validate accepts a background option', async function () { - expect( - (await collection.validate({ full: false, background: true })).valid - ).to.equal(true); - }); - - it('validate fails with background: true and full: true', async function () { - try { - await collection.validate({ full: true, background: true }); - expect.fail('missed exception'); - } catch (err: any) { - expect(err.name).to.equal('MongoServerError'); - } - }); }); }); diff --git a/packages/shell-api/src/replica-set.spec.ts b/packages/shell-api/src/replica-set.spec.ts index e40fa3600..280eda24d 100644 --- a/packages/shell-api/src/replica-set.spec.ts +++ b/packages/shell-api/src/replica-set.spec.ts @@ -32,7 +32,7 @@ import { ALL_TOPOLOGIES, } from './enums'; import { dummyOptions } from './helpers.spec'; -import { signatures, toShellResult } from './index'; +import { Collection, signatures, toShellResult } from './index'; import Mongo from './mongo'; import type { ReplSetConfig, ReplSetMemberConfig } from './replica-set'; import ReplicaSet from './replica-set'; @@ -1057,6 +1057,7 @@ describe('ReplicaSet', function () { ).to.deep.include({ ok: 1 }); }); }); + describe('configureQueryAnalyzer()', function () { skipIfServerVersion(srv0, '< 7.0'); // analyzeShardKey will only be added in 7.0 which is not included in stable yet @@ -1090,6 +1091,41 @@ describe('ReplicaSet', function () { }); }); }); + + describe('validate [replica set mode]', function () { + // Tested here because since https://jira.mongodb.org/browse/MONGOSH-1664 background: true + // does not work on standalone nodes anymore + skipIfApiStrict(); + skipIfServerVersion(srv0, '< 5.0'); + let collection: Collection; + + beforeEach(async function () { + collection = db.getCollection('test'); + await collection.insertOne({ foo: 'bar' }); + }); + + it('validate can be used to validate a collection', async function () { + expect((await collection.validate({ full: true })).valid).to.equal( + true + ); + }); + + it('validate accepts a background option', async function () { + expect( + (await collection.validate({ full: false, background: true })).valid + ).to.equal(true); + }); + + it('validate fails with background: true and full: true', async function () { + try { + await collection.validate({ full: true, background: true }); + expect.fail('missed exception'); + } catch (err: any) { + expect(err.name).to.equal('MongoServerError'); + expect(err.codeName).to.equal('InvalidOptions'); + } + }); + }); }); describe('integration (PA to PSA transition)', function () {