This is an automated email from the ASF dual-hosted git repository.

slbotbm pushed a commit to branch cpp-high-level-client-1
in repository https://gitbox.apache.org/repos/asf/iggy.git


The following commit(s) were added to refs/heads/cpp-high-level-client-1 by 
this push:
     new 785ae28b1 fixes
785ae28b1 is described below

commit 785ae28b1e02ef2ca976581c7da4b8b0d2685f22
Author: Rimuksh Kansal <[email protected]>
AuthorDate: Sat Sep 12 01:51:32 2026 +0900

    fixes
---
 foreign/cpp/src/client.cpp             |   6 +-
 foreign/cpp/tests/e2e/client.cpp       |   1 -
 foreign/cpp/tests/e2e/partition.cpp    | 104 ++++++++++++---------------------
 foreign/cpp/tests/e2e/stream.cpp       |  10 ++--
 foreign/cpp/tests/e2e/test_helpers.hpp |   5 +-
 foreign/cpp/tests/unit/unit_tests.cpp  |   1 +
 6 files changed, 47 insertions(+), 80 deletions(-)

diff --git a/foreign/cpp/src/client.cpp b/foreign/cpp/src/client.cpp
index 1a8546282..3e56a4baf 100644
--- a/foreign/cpp/src/client.cpp
+++ b/foreign/cpp/src/client.cpp
@@ -45,16 +45,16 @@ rust::Vec<ffi::HeaderEntry> ToFfiRawOptions(const 
std::map<std::string, std::str
 
 template <typename FfiOptions, typename Options>
 void SetMutableTopicOptions(FfiOptions &ffi_options, const Options &options) {
-    if (const auto value = options.CompressionAlgorithm()) {
+    if (const auto &value = options.CompressionAlgorithm()) {
         ffi_options.has_compression_algorithm = true;
         ffi_options.compression_algorithm     = std::string(value->Value());
     }
-    if (const auto value = options.MessageExpiry()) {
+    if (const auto &value = options.MessageExpiry()) {
         ffi_options.has_message_expiry   = true;
         ffi_options.message_expiry_kind  = std::string(value->Kind());
         ffi_options.message_expiry_value = value->Value();
     }
-    if (const auto value = options.MaxTopicSize()) {
+    if (const auto &value = options.MaxTopicSize()) {
         ffi_options.has_max_topic_size = true;
         ffi_options.max_topic_size     = std::string(value->Value());
     }
diff --git a/foreign/cpp/tests/e2e/client.cpp b/foreign/cpp/tests/e2e/client.cpp
index d23c201b4..38ae37910 100644
--- a/foreign/cpp/tests/e2e/client.cpp
+++ b/foreign/cpp/tests/e2e/client.cpp
@@ -1752,7 +1752,6 @@ TEST_F(LowLevelE2E_Client, 
ChangePasswordUpdatesCredentialsAndCanBeRestored) {
 
     if (password_changed) {
         EXPECT_NO_THROW(client->change_password(user_id, new_password, 
old_password));
-        password_changed = false;
     }
 
     EXPECT_NO_THROW(third_client->login_user("iggy", old_password));
diff --git a/foreign/cpp/tests/e2e/partition.cpp 
b/foreign/cpp/tests/e2e/partition.cpp
index d72442710..c0ee41b0e 100644
--- a/foreign/cpp/tests/e2e/partition.cpp
+++ b/foreign/cpp/tests/e2e/partition.cpp
@@ -94,45 +94,29 @@ TEST_F(E2E_Partition, 
CreatePartitionsOnNonExistentResourcesThrows) {
         iggy::IggyException);
 }
 
-TEST_F(E2E_Partition, CreatePartitionsWithInvalidIdentifiersThrows) {
-    RecordProperty("description", "Rejects create_partitions requests that use 
malformed stream or topic identifiers.");
+TEST_F(E2E_Partition, CreatePartitionsWithUnknownNumericIdentifiersThrows) {
+    RecordProperty("description",
+                   "Rejects create_partitions requests that use unknown 
numeric stream or topic identifiers.");
     const std::string stream_name = GetRandomName();
     const std::string topic_name  = GetRandomName();
 
-    iggy::ffi::Client *client = GetLoggedInClient();
+    auto client = GetLoggedInHighLevelClient();
 
-    ASSERT_NO_THROW(client->create_stream(stream_name));
+    ASSERT_NO_THROW(client.CreateStream(stream_name));
     TrackStream(stream_name);
-    ASSERT_NO_THROW(client->create_topic(make_string_identifier(stream_name), 
topic_name,
-                                         make_topic_create_options(1, "none", 
"never_expire", 0, "server_default")));
-
-    iggy::ffi::Identifier invalid_stream_kind;
-    invalid_stream_kind.kind   = "invalid";
-    invalid_stream_kind.length = 4;
-    invalid_stream_kind.value  = {1, 0, 0, 0};
-    ASSERT_THROW(client->create_partitions(std::move(invalid_stream_kind), 
make_string_identifier(topic_name), 1),
-                 std::exception);
-
-    iggy::ffi::Identifier invalid_stream_length;
-    invalid_stream_length.kind   = "numeric";
-    invalid_stream_length.length = 1;
-    invalid_stream_length.value.push_back(1);
-    ASSERT_THROW(client->create_partitions(std::move(invalid_stream_length), 
make_string_identifier(topic_name), 1),
-                 std::exception);
-
-    iggy::ffi::Identifier invalid_topic_kind;
-    invalid_topic_kind.kind   = "invalid";
-    invalid_topic_kind.length = 4;
-    invalid_topic_kind.value  = {1, 0, 0, 0};
-    
ASSERT_THROW(client->create_partitions(make_string_identifier(stream_name), 
std::move(invalid_topic_kind), 1),
-                 std::exception);
-
-    iggy::ffi::Identifier invalid_topic_length;
-    invalid_topic_length.kind   = "numeric";
-    invalid_topic_length.length = 1;
-    invalid_topic_length.value.push_back(1);
-    
ASSERT_THROW(client->create_partitions(make_string_identifier(stream_name), 
std::move(invalid_topic_length), 1),
-                 std::exception);
+    ASSERT_NO_THROW(client.CreateTopic(iggy::Identifier::String(stream_name), 
topic_name,
+                                       
iggy::TopicCreateOptions().SetPartitionsCount(1)));
+
+    const auto stream = 
client.GetStream(iggy::Identifier::String(stream_name));
+    ASSERT_EQ(stream.Topics().size(), 1u);
+    const auto unknown_id = std::numeric_limits<std::uint32_t>::max();
+
+    ASSERT_THROW(client.CreatePartitions(iggy::Identifier::Numeric(unknown_id),
+                                         
iggy::Identifier::Numeric(stream.Topics().front().Id()), 1),
+                 iggy::IggyException);
+    ASSERT_THROW(
+        client.CreatePartitions(iggy::Identifier::Numeric(stream.Id()), 
iggy::Identifier::Numeric(unknown_id), 1),
+        iggy::IggyException);
 }
 
 TEST_F(E2E_Partition, CreatePartitionsWithBoundaryPartitionsCountValues) {
@@ -398,45 +382,29 @@ TEST_F(E2E_Partition, 
DeletePartitionsOnNonExistentResourcesThrows) {
         iggy::IggyException);
 }
 
-TEST_F(E2E_Partition, DeletePartitionsWithInvalidIdentifiersThrows) {
-    RecordProperty("description", "Rejects delete_partitions requests that use 
malformed stream or topic identifiers.");
+TEST_F(E2E_Partition, DeletePartitionsWithUnknownNumericIdentifiersThrows) {
+    RecordProperty("description",
+                   "Rejects delete_partitions requests that use unknown 
numeric stream or topic identifiers.");
     const std::string stream_name = GetRandomName();
     const std::string topic_name  = GetRandomName();
 
-    iggy::ffi::Client *client = GetLoggedInClient();
+    auto client = GetLoggedInHighLevelClient();
 
-    ASSERT_NO_THROW(client->create_stream(stream_name));
+    ASSERT_NO_THROW(client.CreateStream(stream_name));
     TrackStream(stream_name);
-    ASSERT_NO_THROW(client->create_topic(make_string_identifier(stream_name), 
topic_name,
-                                         make_topic_create_options(3, "none", 
"never_expire", 0, "server_default")));
-
-    iggy::ffi::Identifier invalid_stream_kind;
-    invalid_stream_kind.kind   = "invalid";
-    invalid_stream_kind.length = 4;
-    invalid_stream_kind.value  = {1, 0, 0, 0};
-    ASSERT_THROW(client->delete_partitions(std::move(invalid_stream_kind), 
make_string_identifier(topic_name), 1),
-                 std::exception);
-
-    iggy::ffi::Identifier invalid_stream_length;
-    invalid_stream_length.kind   = "numeric";
-    invalid_stream_length.length = 1;
-    invalid_stream_length.value.push_back(1);
-    ASSERT_THROW(client->delete_partitions(std::move(invalid_stream_length), 
make_string_identifier(topic_name), 1),
-                 std::exception);
-
-    iggy::ffi::Identifier invalid_topic_kind;
-    invalid_topic_kind.kind   = "invalid";
-    invalid_topic_kind.length = 4;
-    invalid_topic_kind.value  = {1, 0, 0, 0};
-    
ASSERT_THROW(client->delete_partitions(make_string_identifier(stream_name), 
std::move(invalid_topic_kind), 1),
-                 std::exception);
-
-    iggy::ffi::Identifier invalid_topic_length;
-    invalid_topic_length.kind   = "numeric";
-    invalid_topic_length.length = 1;
-    invalid_topic_length.value.push_back(1);
-    
ASSERT_THROW(client->delete_partitions(make_string_identifier(stream_name), 
std::move(invalid_topic_length), 1),
-                 std::exception);
+    ASSERT_NO_THROW(client.CreateTopic(iggy::Identifier::String(stream_name), 
topic_name,
+                                       
iggy::TopicCreateOptions().SetPartitionsCount(3)));
+
+    const auto stream = 
client.GetStream(iggy::Identifier::String(stream_name));
+    ASSERT_EQ(stream.Topics().size(), 1u);
+    const auto unknown_id = std::numeric_limits<std::uint32_t>::max();
+
+    ASSERT_THROW(client.DeletePartitions(iggy::Identifier::Numeric(unknown_id),
+                                         
iggy::Identifier::Numeric(stream.Topics().front().Id()), 1),
+                 iggy::IggyException);
+    ASSERT_THROW(
+        client.DeletePartitions(iggy::Identifier::Numeric(stream.Id()), 
iggy::Identifier::Numeric(unknown_id), 1),
+        iggy::IggyException);
 }
 
 TEST_F(E2E_Partition, DeletePartitionsTwiceForSameTopicSucceeds) {
diff --git a/foreign/cpp/tests/e2e/stream.cpp b/foreign/cpp/tests/e2e/stream.cpp
index d6c633b26..c02ec4c20 100644
--- a/foreign/cpp/tests/e2e/stream.cpp
+++ b/foreign/cpp/tests/e2e/stream.cpp
@@ -644,13 +644,13 @@ TEST_F(E2E_Stream, PurgeStreamPreservesStreamMetadata) {
     EXPECT_GT(stream_with_messages.SizeBytes(), 0u);
 
     struct TopicMetadata {
-        std::uint32_t id;
-        std::uint64_t created_at;
+        std::uint32_t id{};
+        std::uint64_t created_at{};
         std::string name;
-        std::uint64_t message_expiry;
+        std::uint64_t message_expiry{};
         std::string compression_algorithm;
-        std::uint64_t max_topic_size;
-        std::uint32_t partitions_count;
+        std::uint64_t max_topic_size{};
+        std::uint32_t partitions_count{};
     };
     std::unordered_map<std::string, TopicMetadata> topics_before_purge;
     for (const auto &topic : stream_with_messages.Topics()) {
diff --git a/foreign/cpp/tests/e2e/test_helpers.hpp 
b/foreign/cpp/tests/e2e/test_helpers.hpp
index e2f43efec..3751311ee 100644
--- a/foreign/cpp/tests/e2e/test_helpers.hpp
+++ b/foreign/cpp/tests/e2e/test_helpers.hpp
@@ -63,7 +63,7 @@ inline rust::Vec<std::uint8_t> 
partition_id_bytes(std::uint32_t id) {
 
 inline rust::Vec<rust::String> make_snapshot_types(std::initializer_list<const 
char *> values) {
     rust::Vec<rust::String> snapshot_types;
-    for (const auto value : values) {
+    for (const auto *const value : values) {
         snapshot_types.push_back(value);
     }
     return snapshot_types;
@@ -128,7 +128,7 @@ struct TrackedConsumerGroup {
 
 class E2ETestFixture : public ::testing::Test {
   public:
-    ~E2ETestFixture() { CleanupBestEffort(); }
+    ~E2ETestFixture() override { CleanupBestEffort(); }
     void TearDown() override { Cleanup(); }
 
   protected:
@@ -404,7 +404,6 @@ class E2ETestFixture : public ::testing::Test {
                !tracked_user_names_.empty();
     }
 
-  private:
     std::vector<iggy::ffi::Client *> clients_;
     std::vector<std::string> tracked_user_names_;
     std::vector<std::string> tracked_stream_names_;
diff --git a/foreign/cpp/tests/unit/unit_tests.cpp 
b/foreign/cpp/tests/unit/unit_tests.cpp
index 840247c86..3f6c6fa4f 100644
--- a/foreign/cpp/tests/unit/unit_tests.cpp
+++ b/foreign/cpp/tests/unit/unit_tests.cpp
@@ -346,6 +346,7 @@ TEST(IggyBlockingClientTest, MovedFromOperationsThrow) {
     const auto stream = iggy::Identifier::String("stream");
     const auto topic  = iggy::Identifier::String("topic");
 
+    // Exercising the moved-from guard requires invoking every operation on 
the valid but empty source object.
     EXPECT_THROW(client.Connect(), iggy::IggyException);
     EXPECT_THROW(client.Disconnect(), iggy::IggyException);
     EXPECT_THROW(client.Shutdown(), iggy::IggyException);

Reply via email to