diff options
author | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-02-28 14:37:24 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-02-28 14:37:24 +0000 |
commit | 58b12f743d63df3f36373193dc5319cba4cf06d7 (patch) | |
tree | fc32ec4106a0ad869e4af67638a0e3273861ce0d /searchcore/src | |
parent | 24745931ba1486374da2f7cf98fec4b91d712c12 (diff) |
Check bucket id and time stamp when checking deserialization.
Move generation of document update to helper method.
Diffstat (limited to 'searchcore/src')
-rw-r--r-- | searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp b/searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp index f82ac938bc0..a49127a44f4 100644 --- a/searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp +++ b/searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp @@ -101,6 +101,14 @@ public: _docType(*_repo->getDocumentType(type_name)) { } + + auto makeUpdate() { + auto upd(std::make_shared<DocumentUpdate>(_docType, docId)); + upd->addUpdate(FieldUpdate(upd->getType().getField("string")). + addUpdate(AssignValueUpdate(StringFieldValue("newval")))); + return upd; + } + }; TEST("require that toString() on derived classes are meaningful") @@ -229,34 +237,36 @@ TEST("require that serialize/deserialize works for CompactLidSpaceOperation") TEST_F("require that we can serialize and deserialize update operations", Fixture) { vespalib::nbostream stream; - auto upd(std::make_shared<DocumentUpdate>(f._docType, docId)); - upd->addUpdate(FieldUpdate(upd->getType().getField("string")). - addUpdate(AssignValueUpdate(StringFieldValue("newval")))); + BucketId bucket(toBucket(docId.getGlobalId())); + auto upd(f.makeUpdate()); { - UpdateOperation op(toBucket(docId.getGlobalId()), Timestamp(10), upd); + UpdateOperation op(bucket, Timestamp(10), upd); op.serialize(stream); } { UpdateOperation op; op.deserialize(stream, *f._repo); EXPECT_EQUAL(*upd, *op.getUpdate()); + EXPECT_EQUAL(bucket, op.getBucketId()); + EXPECT_EQUAL(10, op.getTimestamp().getValue()); } } TEST_F("require that we can deserialize old update operations", Fixture) { vespalib::nbostream stream; - auto upd(std::make_shared<DocumentUpdate>(f._docType, docId)); - upd->addUpdate(FieldUpdate(upd->getType().getField("string")). - addUpdate(AssignValueUpdate(StringFieldValue("newval")))); + BucketId bucket(toBucket(docId.getGlobalId())); + auto upd(f.makeUpdate()); { - UpdateOperation op(UpdateOperation::makeOldUpdate(toBucket(docId.getGlobalId()), Timestamp(10), upd)); + UpdateOperation op(UpdateOperation::makeOldUpdate(bucket, Timestamp(10), upd)); op.serialize(stream); } { UpdateOperation op(FeedOperation::UPDATE_42); op.deserialize(stream, *f._repo); EXPECT_EQUAL(*upd, *op.getUpdate()); + EXPECT_EQUAL(bucket, op.getBucketId()); + EXPECT_EQUAL(10, op.getTimestamp().getValue()); } } |