diff options
author | Shaun Verch <shaun.verch@10gen.com> | 2013-03-28 10:41:57 -0400 |
---|---|---|
committer | Shaun Verch <shaun.verch@10gen.com> | 2013-03-29 09:34:44 -0400 |
commit | 0b6737c2ddd58df25eb41c477c9dc639014b0ebe (patch) | |
tree | 3e9c2a0cc5988f4044cb555762866e83085cfa44 /src/mongo/dbtests/jstests.cpp | |
parent | 2dc4f569adf4b66a2b9f4500de521c9cdf7ba73b (diff) | |
download | mongo-0b6737c2ddd58df25eb41c477c9dc639014b0ebe.tar.gz |
SERVER-9082 Accept any valid value in id field of dbref
Diffstat (limited to 'src/mongo/dbtests/jstests.cpp')
-rw-r--r-- | src/mongo/dbtests/jstests.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mongo/dbtests/jstests.cpp b/src/mongo/dbtests/jstests.cpp index a95c5db3ded..b17338bc0e5 100644 --- a/src/mongo/dbtests/jstests.cpp +++ b/src/mongo/dbtests/jstests.cpp @@ -1061,6 +1061,32 @@ namespace JSTests { class InformalDBRefTest : public TestRoundTrip { virtual BSONObj bson() const { BSONObjBuilder b; + BSONObjBuilder subBuilder(b.subobjStart("a")); + subBuilder.append("$ref", "ns"); + subBuilder.append("$id", "000000000000000000000000"); + subBuilder.done(); + return b.obj(); + } + + // Don't need to return anything because we are overriding both jsonOut and jsonIn + virtual string json() const { return ""; } + + // Need to override these because the JSON doesn't actually round trip. + // An object with "$ref" and "$id" fields is handled specially and different on the way out. + virtual string jsonOut() const { + return "{ \"a\" : DBRef( \"ns\", \"000000000000000000000000\" ) }"; + } + virtual string jsonIn() const { + stringstream ss; + ss << "{ \"a\" : { \"$ref\" : \"ns\" , " << + "\"$id\" : \"000000000000000000000000\" } }"; + return ss.str(); + } + }; + + class InformalDBRefOIDTest : public TestRoundTrip { + virtual BSONObj bson() const { + BSONObjBuilder b; OID o; memset( &o, 0, 12 ); BSONObjBuilder subBuilder(b.subobjStart("a")); @@ -1387,6 +1413,7 @@ namespace JSTests { add< RoundTripTests::DBRefTest >(); add< RoundTripTests::DBPointerTest >(); add< RoundTripTests::InformalDBRefTest >(); + add< RoundTripTests::InformalDBRefOIDTest >(); add< RoundTripTests::InformalDBRefExtraFieldTest >(); add< NoReturnSpecified >(); } |