-
Notifications
You must be signed in to change notification settings - Fork 189
/
Copy pathrtc.test.js
91 lines (83 loc) · 2.92 KB
/
rtc.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const should = require('should');
const assert = require('assert');
const qiniu = require('../index.js');
const proc = require('process');
const console = require('console');
// eslint-disable-next-line no-undef
before(function (done) {
if (!process.env.QINIU_ACCESS_KEY || !process.env.QINIU_SECRET_KEY) {
console.log('should run command `source test-env.sh` first\n');
process.exit(0);
}
done();
});
// eslint-disable-next-line no-undef
describe('test rtc credentials', function () {
this.timeout(10000);
var accessKey = proc.env.QINIU_ACCESS_KEY;
var secretKey = proc.env.QINIU_SECRET_KEY;
var credentials = new qiniu.Credentials(accessKey, secretKey);
var appId = null;
var appData = {
hub: 'hailong',
title: 'testtitle',
maxUsers: 10,
noAutoKickUser: true
};
after(function (done) {
qiniu.app.deleteApp(appId, credentials, function () {
done();
});
});
// eslint-disable-next-line no-undef
describe('test create app', function () {
// eslint-disable-next-line no-undef
it('create app', function (done) {
qiniu.app.createApp(appData, credentials, function (err, res) {
should.not.exist(err);
should.exist(res.appId);
assert.strictEqual(res.title, 'testtitle');
appId = res.appId;
done();
});
});
});
// eslint-disable-next-line no-undef
describe('test update app', function () {
// eslint-disable-next-line no-undef
it('update app', function (done) {
should.ok(appId, 'appId not found. May create failed');
appData.title = 'testtitle2';
qiniu.app.updateApp(appId, appData, credentials, function (err, res) {
should.not.exist(err);
assert.strictEqual(res.title, 'testtitle2');
assert.strictEqual(res.appId, appId);
done();
});
});
});
// eslint-disable-next-line no-undef
describe('test get app', function () {
// eslint-disable-next-line no-undef
it('get app', function (done) {
should.ok(appId, 'appId not found. May create failed');
qiniu.app.getApp(appId, credentials, function (err, res) {
should.not.exist(err);
assert.strictEqual(res.title, 'testtitle2');
assert.strictEqual(res.appId, appId);
done();
});
});
});
// eslint-disable-next-line no-undef
describe('test delete app', function () {
// eslint-disable-next-line no-undef
it('delete app', function (done) {
should.ok(appId, 'appId not found. May create failed');
qiniu.app.deleteApp(appId, credentials, function (err) {
should.not.exist(err);
done();
});
});
});
});