jstests/core/cover_null_queries.js
/**
 * Runs an aggregation with a $count stage with the 'filter' applied to the $match stage and
 * validates that the count returned matches 'expectedCount'. Also runs explain() command on the
 * and validates that all the 'expectedStages' are present in the plan returned.
 */
Runs an aggregation with a $count stage with the 'filter' applied to the $match stage and
validates that the count returned matches 'expectedCount'. Also runs explain() command on the
and validates that all the 'expectedStages' are present in the plan returned.
Runs an aggregation with a $count stage with the ' filter ' applied to the $match stage and validates that the count returned matches ' expectedCount ' . Also runs explain () command on the and validates that all the ' expectedStages ' are present in the plan returned .
function validateCountAggCmdOutputAndPlan({filter, expectedStages, expectedCount, pipeline}) {
    const cmdObj = {
        aggregate: coll.getName(),
        pipeline: pipeline || [{$match: filter}, {$count: "count"}],
        cursor: {},
    };
    const cmdRes = assert.commandWorked(coll.runCommand(cmdObj));
    const countRes = cmdRes.cursor.firstBatch;
    assert.eq(countRes.length, 1, cmdRes);
    assert.eq(countRes[0].count, expectedCount, countRes);
    validateStages({cmdObj, expectedStages, isAgg: true});
}
function validateCountAggCmdOutputAndPlan ( { filter , expectedStages , expectedCount , pipeline } ) { const cmdObj = { aggregate : coll . getName ( ) , pipeline : pipeline || [ { $match : filter } , { $count : "count" } ] , cursor : { } , } ; const cmdRes = assert . commandWorked ( coll . runCommand ( cmdObj ) ) ; const countRes = cmdRes . cursor . firstBatch ; assert . eq ( countRes . length , 1 , cmdRes ) ; assert . eq ( countRes [ 0 ] . count , expectedCount , countRes ) ; validateStages ( { cmdObj , expectedStages , isAgg : true } ) ; }
Runs an aggregation with a $count stage with the 'filter' applied to the $match stage and
 validates that the count returned matches 'expectedCount'.
Runs an aggregation with a $count stage with the ' filter ' applied to the $match stage and validates that the count returned matches ' expectedCount ' .