isapego commented on code in PR #6352:
URL: https://github.com/apache/ignite-3/pull/6352#discussion_r2245886962


##########
modules/platforms/cpp/tests/client-test/transactions_test.cpp:
##########
@@ -434,3 +434,53 @@ TEST_F(transactions_test, record_view_remove_all_exact) {
     auto values2 = record_view.remove_all(nullptr, {value0});
     ASSERT_TRUE(values2.empty());
 }
+
+TEST_F(transactions_test, tx_successful_when_timeout_does_not_exceed) {
+    auto record_view = 
m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();
+
+    int64_t key = 42;
+    std::string val = "Lorem ipsum";
+    auto tx = m_client.get_transactions().begin(transaction_options 
{.timeoutMillis = 10'000L, .readOnly = true});
+
+    record_view.insert(nullptr, get_tuple(key, val));
+
+    tx.commit();
+
+    auto value = record_view.get(nullptr, get_tuple(42));
+
+    ASSERT_TRUE(value.has_value());
+    EXPECT_EQ(key, value->get<int64_t>(KEY_COLUMN));
+    EXPECT_EQ(val, value->get<std::string>(VAL_COLUMN));
+}
+
+
+TEST_F(transactions_test, tx_failed_when_timeout_exceeds) {
+    auto record_view = 
m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();
+
+    auto timeout = std::chrono::seconds{1};
+
+    int64_t key = 42;
+    std::string val = "Lorem ipsum";
+    auto tx_opts = transaction_options {
+        .timeoutMillis = 
std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count(),
+        .readOnly = false};
+
+    auto tx = m_client.get_transactions().begin(tx_opts);
+
+    record_view.insert(&tx, get_tuple(key, val));
+
+    std::this_thread::sleep_for(timeout * 2);
+
+    EXPECT_THROW(
+        {
+            try {
+                // TODO change to check tx.commit when IGNITE-24233 is 
implemented
+                // tx.commit();
+                [[maybe_unused]]auto rec = record_view.get(&tx, 
get_tuple(key));

Review Comment:
   Let's avoid `[[maybe_unused]]` it's not supported very well by Microsoft 
unfortunately.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to