BewareMyPower commented on code in PR #409:
URL: https://github.com/apache/pulsar-client-cpp/pull/409#discussion_r1519299700


##########
tests/ReaderTest.cc:
##########
@@ -784,4 +784,56 @@ TEST(ReaderSeekTest, testStartAtLatestMessageId) {
     producer.close();
 }
 
+TEST(ReaderTest, testSeekInProgress) {
+    Client client(serviceUrl);
+    const auto topic = "test-seek-in-progress-" + 
std::to_string(time(nullptr));
+    Reader reader;
+    ASSERT_EQ(ResultOk, client.createReader(topic, MessageId::earliest(), {}, 
reader));
+
+    reader.seekAsync(MessageId::earliest(), [](Result) {});
+    Promise<Result, Result> promise;
+    reader.seekAsync(MessageId::earliest(), [promise](Result result) { 
promise.setValue(result); });
+    Result result;
+    promise.getFuture().get(result);
+    ASSERT_EQ(result, ResultNotAllowedError);
+    client.close();
+}
+
+TEST_P(ReaderTest, testHasMessageAvailableAfterSeekToEnd) {
+    Client client(serviceUrl);
+    const auto topic = "test-has-message-available-after-seek-to-end-" + 
std::to_string(time(nullptr));
+    Producer producer;
+    ASSERT_EQ(ResultOk, client.createProducer(topic, producer));
+    Reader reader;
+    ASSERT_EQ(ResultOk, client.createReader(topic, MessageId::earliest(), {}, 
reader));
+
+    producer.send(MessageBuilder().setContent("msg-0").build());
+    producer.send(MessageBuilder().setContent("msg-1").build());
+
+    bool hasMessageAvailable;
+    if (GetParam()) {

Review Comment:
   Emmm. Actually I use a different meaning for this bool param because if 
`hasMessageAvailable` has been called before `seek`, the 
`lastmessageIdInBroker_` will be initialized and the logic of the following 
`has MessageAvailable` will be different.



-- 
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