From cda0f92f1bf4b6c2635d16d0a9fda2734fb6ebea Mon Sep 17 00:00:00 2001 From: Gabor Gyimesi Date: Mon, 14 Oct 2024 10:29:17 +0200 Subject: [PATCH] Refactor --- extensions/couchbase/tests/MockCouchbaseClusterService.h | 7 ++++++- extensions/couchbase/tests/PutCouchbaseKeyTests.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/extensions/couchbase/tests/MockCouchbaseClusterService.h b/extensions/couchbase/tests/MockCouchbaseClusterService.h index 5f2bc08a6a..521ab3bdff 100644 --- a/extensions/couchbase/tests/MockCouchbaseClusterService.h +++ b/extensions/couchbase/tests/MockCouchbaseClusterService.h @@ -25,6 +25,11 @@ using namespace std::literals::chrono_literals; namespace org::apache::nifi::minifi::couchbase::test { +const std::uint64_t COUCHBASE_PUT_RESULT_CAS = 9876; +const std::uint64_t COUCHBASE_PUT_RESULT_SEQUENCE_NUMBER = 345; +const std::uint64_t COUCHBASE_PUT_RESULT_PARTITION_UUID = 7890123456; +const std::uint16_t COUCHBASE_PUT_RESULT_PARTITION_ID = 1234; + struct UpsertParameters { std::string document_id; std::vector buffer; @@ -50,7 +55,7 @@ class MockCouchbaseClusterService : public controllers::CouchbaseClusterService if (upsert_error_) { return nonstd::make_unexpected(*upsert_error_); } else { - return CouchbaseUpsertResult{std::string(collection_.bucket_name), 1, 2, 3, 4}; + return CouchbaseUpsertResult{collection_.bucket_name, COUCHBASE_PUT_RESULT_CAS, COUCHBASE_PUT_RESULT_SEQUENCE_NUMBER, COUCHBASE_PUT_RESULT_PARTITION_UUID, COUCHBASE_PUT_RESULT_PARTITION_ID}; } } diff --git a/extensions/couchbase/tests/PutCouchbaseKeyTests.cpp b/extensions/couchbase/tests/PutCouchbaseKeyTests.cpp index ec2272d33a..b65f39d00a 100644 --- a/extensions/couchbase/tests/PutCouchbaseKeyTests.cpp +++ b/extensions/couchbase/tests/PutCouchbaseKeyTests.cpp @@ -94,10 +94,10 @@ class PutCouchbaseKeyTestController : public TestController { CHECK(flow_file->getAttribute("couchbase.bucket").value() == expected_call_options.bucket_name); CHECK(flow_file->getAttribute("couchbase.doc.id").value() == expected_doc_id); - CHECK(flow_file->getAttribute("couchbase.doc.cas").value() == "1"); - CHECK(flow_file->getAttribute("couchbase.doc.sequence.number").value() == "2"); - CHECK(flow_file->getAttribute("couchbase.partition.uuid").value() == "3"); - CHECK(flow_file->getAttribute("couchbase.partition.id").value() == "4"); + CHECK(flow_file->getAttribute("couchbase.doc.cas").value() == std::to_string(COUCHBASE_PUT_RESULT_CAS)); + CHECK(flow_file->getAttribute("couchbase.doc.sequence.number").value() == std::to_string(COUCHBASE_PUT_RESULT_SEQUENCE_NUMBER)); + CHECK(flow_file->getAttribute("couchbase.partition.uuid").value() == std::to_string(COUCHBASE_PUT_RESULT_PARTITION_UUID)); + CHECK(flow_file->getAttribute("couchbase.partition.id").value() == std::to_string(COUCHBASE_PUT_RESULT_PARTITION_ID)); } protected: