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