RobertIndie commented on code in PR #1221:
URL: https://github.com/apache/pulsar-client-go/pull/1221#discussion_r1615909089


##########
pulsar/consumer_multitopic_test.go:
##########
@@ -137,3 +137,69 @@ func TestMultiTopicConsumerForceUnsubscribe(t *testing.T) {
        err = consumer.UnsubscribeForce()
        assert.Error(t, err)
 }
+
+func TestMultiTopicGetLastMessageIDs(t *testing.T) {
+       client, err := NewClient(ClientOptions{
+               URL: lookupURL,
+       })
+
+       assert.Nil(t, err)
+       defer client.Close()
+
+       topic1Partition, topic2Partition, topic3Partition := 1, 2, 3
+
+       topic1 := newTopicName()
+       err = createPartitionedTopic(topic1, topic1Partition)
+       assert.Nil(t, err)
+
+       topic2 := newTopicName()
+       err = createPartitionedTopic(topic2, topic2Partition)
+       assert.Nil(t, err)
+
+       topic3 := newTopicName()
+       err = createPartitionedTopic(topic3, topic3Partition)
+       assert.Nil(t, err)
+
+       topics := []string{topic1, topic2, topic3}
+       // create consumer
+       consumer, err := client.Subscribe(ConsumerOptions{
+               Topics:           topics,
+               SubscriptionName: "my-sub",
+               Type:             Shared,
+       })
+       assert.Nil(t, err)
+       defer consumer.Close()
+
+       // produce messages
+       totalMessage := 30
+       for i, topic := range topics {
+               p, err := client.CreateProducer(ProducerOptions{
+                       Topic:           topic,
+                       DisableBatching: true,
+               })
+               if err != nil {
+                       t.Fatal(err)
+               }
+               err = genMessages(p, totalMessage, func(idx int) string {
+                       return fmt.Sprintf("topic-%d-hello-%d", i+1, idx)
+               })
+               p.Close()
+               if err != nil {
+                       assert.Nil(t, err)
+               }
+       }
+
+       topicMessageIDs, err := consumer.GetLastMessageIDs()
+       assert.Nil(t, err)
+       assert.Equal(t, topic1Partition+topic2Partition+topic3Partition, 
len(topicMessageIDs))
+       for _, id := range topicMessageIDs {

Review Comment:
   A better approach is to use a map to store `topic1`, `topic2` and `topic3` 
and their corresponding messages count. So that we can assert if the `id` here 
matches one of them.



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