it('listServices should ok', async function () { const response = await client.listServices(); expect(response.data).to.be.ok(); expect(response.data.services).to.be.ok(); expect(response.data.services.length).to.above(0); const [service] = response.data.services; expect(service).to.have.property('serviceName'); });
before(async function () { // clean up try { await client.deleteService(serviceName); } catch (ex) { // Ignore } const service = await client.createService(serviceName); expect(service.data).to.be.ok(); expect(service.data).to.have.property('serviceName', serviceName); });
it('stream', function(callback) { let i = 0; let error = null; clickhouse.query(sql).stream() .on('data', () => ++i) .on('error', err => error = err) .on('end', () => { expect(error).to.not.be.ok(); expect(i).to.be(rowCount); callback(); }); });
it('batchDeleteMessage shoule ok', async function() { const recived = await client.batchReceiveMessage(queueName, 2); expect(recived).to.be.ok(); expect(recived.code).to.be(200); const messageIds = recived.body.map((item) => { return item.ReceiptHandle; }); const res = await client.batchDeleteMessage(queueName, messageIds); expect(res).to.be.ok(); expect(res.code).to.be(204); });
it('list aliases', async function () { const res = await client.listAliases(1, 100); expect(res.TotalCount).to.be(2); expect(Array.isArray(res.Aliases.Alias)).to.be.ok(); expect(res.Aliases.Alias.length).to.be(2); });
it(`create alias after retry ${retry}times`, async function () { // with no backoff_period let res = await client.createAlias(keyId, alias, authOption); expect(res && typeof res === 'object').to.be.ok(); expect(res.HttpStatus !== 400).to.be.ok(); expect(res.RequestId && typeof res.RequestId === 'string').to.be.ok(); // with backoff_period res = await client.createAlias(keyId, alias, runtimeOption); expect(res && typeof res === 'object').to.be.ok(); expect(res.HttpStatus !== 400).to.be.ok(); expect(res.RequestId && typeof res.RequestId === 'string').to.be.ok(); });
it('Bone.renameAttribute(name, newName)', async function() { Post.renameAttribute('thumb', 'thumbnail'); const post = await Post.findOne({ thumbnail: { $ne: null } }); expect(post.thumbnail).not.to.be(undefined); Post.renameAttribute('thumbnail', 'thumb'); const post2 = await Post.findOne({ thumb: { $ne: null } }); expect(post2.thumb).to.be.ok(); });
it('ackMessage handle is illegal should ok', async function() { const handles = ['adfadfadfadf', 'xxxxx']; const res = await consumer.ackMessage(handles); expect(res).to.be.ok(); expect(res.code).to.be(404); res.body.map((item) => { expect(item).to.have.property('ErrorCode'); expect(item).to.have.property('ErrorMessage'); expect(item).to.have.property('ReceiptHandle'); expect(item.ErrorCode).to.be('ReceiptHandleError'); }); });
it('.findOne()', async function() { const post = await Post.findOne(); expect(post).to.be.a(Post); expect(post.id).to.be.ok(); });
it('listTopic should ok', async function() { const response = await client.listTopic(); expect(response).to.be.ok(); expect(response.code).to.be(200); const body = response.body; expect(body.length).to.above(0); const [topic] = body; expect(topic).to.have.property('TopicURL', `http://${ACCOUNT_ID}.mns.cn-shanghai.aliyuncs.com/topics/test-topic`); });
it('deleteQueue shoule ok', async function() { const res = await client.deleteQueue(queueName); expect(res).to.be.ok(); expect(res.code).to.be(204); });
it(`delete alias after retry ${retry} times`, async function () { // with no backoff_period let res = await client.deleteAlias(alias, authOption); expect(res && typeof res === 'object').to.be.ok(); expect(res.HttpStatus !== 400).to.be.ok(); expect(res.RequestId && typeof res.RequestId === 'string').to.be.ok(); // with backoff_period res = await client.deleteAlias(alias, runtimeOption); expect(res && typeof res === 'object').to.be.ok(); expect(res.HttpStatus !== 400).to.be.ok(); expect(res.RequestId && typeof res.RequestId === 'string').to.be.ok(); });
it('createTopic should ok', async function() { const response = await client.createTopic(topicName); expect(response).to.be.ok(); expect(response.code >= 200 && response.code < 300).to.be.ok(); expect(response.headers).to.have.property('location', `http://${ACCOUNT_ID}.mns.cn-shanghai.aliyuncs.com/topics/test-topic`); });
it('setTopicAttributes should ok', async function() { const response = await client.setTopicAttributes(topicName); expect(response).to.be.ok(); expect(response.code).to.be(204); });