|
| 1 | +const should = require('should'); |
| 2 | +const assert = require('assert'); |
| 3 | +const qiniu = require("../index.js"); |
| 4 | +const proc = require("process"); |
| 5 | + |
| 6 | +before(function(done) { |
| 7 | + if (!process.env.QINIU_PILI_ACCESS_KEY || !process.env.QINIU_PILI_SECRET_KEY) { |
| 8 | + console.log('should run command `source test-env.sh` first\n'); |
| 9 | + process.exit(0); |
| 10 | + } |
| 11 | + done(); |
| 12 | +}); |
| 13 | + |
| 14 | +describe('test rtc credentials', function() { |
| 15 | + var accessKey = proc.env.QINIU_ACCESS_KEY; |
| 16 | + var secretKey = proc.env.QINIU_SECRET_KEY; |
| 17 | + |
| 18 | + var credentials = new qiniu.Credentials(accessKey, secretKey); |
| 19 | + var appId = null; |
| 20 | + var appData = { |
| 21 | + hub: 'sdk-live', |
| 22 | + title: 'testtitle', |
| 23 | + maxUsers: 10, |
| 24 | + noAutoKickUser: true, |
| 25 | + }; |
| 26 | + describe('test create app', function() { |
| 27 | + it('create app', function(done) { |
| 28 | + qiniu.app.createApp(appData, credentials, function(err, res) { |
| 29 | + should.not.exist(err); |
| 30 | + should.exist(res.appId); |
| 31 | + assert.equal(res.title, 'testtitle'); |
| 32 | + appId = res.appId; |
| 33 | + done(); |
| 34 | + }); |
| 35 | + }); |
| 36 | + }); |
| 37 | + |
| 38 | + describe('test update app', function() { |
| 39 | + it('update app', function(done) { |
| 40 | + appData.title = 'testtitle2'; |
| 41 | + qiniu.app.updateApp(appId, appData, credentials, function(err, res) { |
| 42 | + should.not.exist(err); |
| 43 | + assert.equal(res.title, 'testtitle2'); |
| 44 | + assert.equal(res.appId, appId); |
| 45 | + done(); |
| 46 | + }); |
| 47 | + }) |
| 48 | + }); |
| 49 | + |
| 50 | + describe('test get app', function() { |
| 51 | + it('get app', function(done) { |
| 52 | + qiniu.app.getApp(appId, credentials, function(err, res) { |
| 53 | + should.not.exist(err); |
| 54 | + assert.equal(res.title, 'testtitle2'); |
| 55 | + assert.equal(res.appId, appId); |
| 56 | + done(); |
| 57 | + }) |
| 58 | + }); |
| 59 | + }); |
| 60 | + |
| 61 | + describe('test delete app', function() { |
| 62 | + it('delete app', function(done) { |
| 63 | + qiniu.app.deleteApp(appId, credentials, function(err, res) { |
| 64 | + should.not.exist(err); |
| 65 | + done(); |
| 66 | + }) |
| 67 | + }) |
| 68 | + }); |
| 69 | +}); |
0 commit comments