Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lordgamez committed Oct 14, 2024
1 parent d4e8f14 commit cda0f92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion extensions/couchbase/tests/MockCouchbaseClusterService.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::byte> buffer;
Expand All @@ -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};
}
}

Expand Down
8 changes: 4 additions & 4 deletions extensions/couchbase/tests/PutCouchbaseKeyTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit cda0f92

Please sign in to comment.