summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_facet_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/document_source_facet_test.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_facet_test.cpp53
1 files changed, 35 insertions, 18 deletions
diff --git a/src/mongo/db/pipeline/document_source_facet_test.cpp b/src/mongo/db/pipeline/document_source_facet_test.cpp
index d8798a5c70e..be05268fb7b 100644
--- a/src/mongo/db/pipeline/document_source_facet_test.cpp
+++ b/src/mongo/db/pipeline/document_source_facet_test.cpp
@@ -66,49 +66,60 @@ TEST_F(DocumentSourceFacetTest, ShouldRejectNonObjectSpec) {
auto ctx = getExpCtx();
auto spec = BSON("$facet"
<< "string");
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << 1);
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << BSON_ARRAY(1 << 2));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldRejectEmptyObject) {
auto ctx = getExpCtx();
auto spec = BSON("$facet" << BSONObj());
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldRejectFacetsWithInvalidNames) {
auto ctx = getExpCtx();
auto spec = BSON("$facet" << BSON("" << BSON_ARRAY(BSON("$skip" << 4))));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << BSON("a.b" << BSON_ARRAY(BSON("$skip" << 4))));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << BSON("$a" << BSON_ARRAY(BSON("$skip" << 4))));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldRejectNonArrayFacets) {
auto ctx = getExpCtx();
auto spec = BSON("$facet" << BSON("a" << 1));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << BSON("a" << BSON_ARRAY(BSON("$skip" << 4)) << "b" << 2));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldRejectEmptyPipelines) {
auto ctx = getExpCtx();
auto spec = BSON("$facet" << BSON("a" << BSONArray()));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << BSON("a" << BSON_ARRAY(BSON("$skip" << 4)) << "b" << BSONArray()));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldSucceedWhenNamespaceIsCollectionless) {
@@ -124,29 +135,35 @@ TEST_F(DocumentSourceFacetTest, ShouldRejectFacetsContainingAnOutStage) {
auto ctx = getExpCtx();
auto spec = BSON("$facet" << BSON("a" << BSON_ARRAY(BSON("$out"
<< "out_collection"))));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec =
BSON("$facet" << BSON("a" << BSON_ARRAY(BSON("$skip" << 1) << BSON("$out"
<< "out_collection"))));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = BSON("$facet" << BSON("a" << BSON_ARRAY(BSON("$out"
<< "out_collection")
<< BSON("$skip" << 1))));
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldRejectFacetsContainingAFacetStage) {
auto ctx = getExpCtx();
auto spec = fromjson("{$facet: {a: [{$facet: {a: [{$skip: 2}]}}]}}");
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = fromjson("{$facet: {a: [{$skip: 2}, {$facet: {a: [{$skip: 2}]}}]}}");
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
spec = fromjson("{$facet: {a: [{$skip: 2}], b: [{$facet: {a: [{$skip: 2}]}}]}}");
- ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx), UserException);
+ ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
+ AssertionException);
}
TEST_F(DocumentSourceFacetTest, ShouldAcceptLegalSpecification) {
@@ -599,7 +616,7 @@ TEST_F(DocumentSourceFacetTest, ShouldThrowIfAnyPipelineRequiresTextScoreButItIs
auto facetStage = DocumentSourceFacet::create(std::move(facets), ctx);
DepsTracker deps(DepsTracker::MetadataAvailable::kNoMetadata);
- ASSERT_THROWS(facetStage->getDependencies(&deps), UserException);
+ ASSERT_THROWS(facetStage->getDependencies(&deps), AssertionException);
}
/**