[GitHub] [pulsar-client-node] shibd commented on a diff in pull request #322: [feat]: Support client.getPartitionsForTopic (#320)

2023-05-08 Thread via GitHub


shibd commented on code in PR #322:
URL: 
https://github.com/apache/pulsar-client-node/pull/322#discussion_r1188061390


##
tests/client.test.js:
##
@@ -49,5 +74,54 @@ const Pulsar = require('../index.js');
 })).toThrow('Service URL is required and must be specified as a 
string');
   });
 });
+describe('test getPartitionsForTopic', () => {
+  test('GetPartitions for empty topic', async () => {
+const client = new Pulsar.Client({
+  serviceUrl: 'pulsar://localhost:6650',
+  operationTimeoutSeconds: 30,
+});
+
+await expect(client.getPartitionsForTopic(''))
+  .rejects.toThrow('Failed to GetPartitionsForTopic: 
InvalidTopicName');
+await client.close();
+  });
+
+  test('Client/getPartitionsForTopic', async () => {
+const client = new Pulsar.Client({
+  serviceUrl: 'pulsar://localhost:6650',
+  operationTimeoutSeconds: 30,
+});
+
+// test on nonPartitionedTopic
+const nonPartitionedTopicName = 'test-non-partitioned-topic';
+const nonPartitionedTopic = 
`persistent://public/default/${nonPartitionedTopicName}`;
+await 
requestAdminApi(`${baseUrl}/admin/v2/persistent/public/default/${nonPartitionedTopicName}`,
 {
+  headers: {
+'Content-Type': 'application/json',
+  },
+});
+const nonPartitionedTopicList = await 
client.getPartitionsForTopic(nonPartitionedTopic);

Review Comment:
   Before this, you should assert the HTTP response code first.



-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [pulsar-client-node] shibd commented on a diff in pull request #322: [feat]: Support client.getPartitionsForTopic (#320)

2023-05-07 Thread via GitHub


shibd commented on code in PR #322:
URL: 
https://github.com/apache/pulsar-client-node/pull/322#discussion_r1186980916


##
tests/end_to_end.test.js:
##
@@ -1242,5 +1242,21 @@ const Pulsar = require('../index.js');
   await consumer.close();
   await client.close();
 });
+
+test('Client/getPartitionsForTopic', async () => {

Review Comment:
   This test should belong `client.test.js`.



##
tests/end_to_end.test.js:
##
@@ -1242,5 +1242,21 @@ const Pulsar = require('../index.js');
   await consumer.close();
   await client.close();
 });
+
+test('Client/getPartitionsForTopic', async () => {
+  const client = new Pulsar.Client({
+serviceUrl: 'pulsar://localhost:6650',
+operationTimeoutSeconds: 30,
+  });
+
+  const topic = 'persistent://public/default/get-partitions-for-topic';
+  await client.createProducer({

Review Comment:
   You can use admin [REST 
API](https://pulsar.apache.org/admin-rest-api/?version=3.0.0#) to create 
specified partitions topic, and then to assert `getPartitionsForTopic`.



-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org