Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(shell-api): Support boolean "true" with currentOp MONGOSH-1131 #1219

Merged
merged 2 commits into from
Mar 10, 2022
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
22 changes: 22 additions & 0 deletions packages/shell-api/src/database.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,28 @@ describe('Database', () => {
{ currentOp: 1 }
);
});
it('allows boolean parameter', async() => {
await database.currentOp(true);

expect(serviceProvider.runCommandWithCheck).to.have.been.calledWith(
ADMIN_DB,
{
currentOp: 1,
$all: true
}
);
});
it('allows boolean parameter false', async() => {
await database.currentOp(false);

expect(serviceProvider.runCommandWithCheck).to.have.been.calledWith(
ADMIN_DB,
{
$all: false,
currentOp: 1
}
);
});
it('calls serviceProvider.runCommandWithCheck on the database with options', async() => {
await database.currentOp({
$ownOps: true,
Expand Down
5 changes: 4 additions & 1 deletion packages/shell-api/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,11 @@ export default class Database extends ShellApiWithMongoClass {

@returnsPromise
@apiVersions([])
async currentOp(opts: Document = {}): Promise<Document> {
async currentOp(opts: Document | boolean = {}): Promise<Document> {
this._emitDatabaseApiCall('currentOp', { opts: opts });
if (typeof opts === 'boolean') {
opts = { $all: opts };
}
return await this._runAdminCommand(
{
currentOp: 1,
Expand Down