-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtestDnsRecord.js
More file actions
107 lines (87 loc) · 2.91 KB
/
testDnsRecord.js
File metadata and controls
107 lines (87 loc) · 2.91 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
var pkgcloud = require('pkgcloud'),
logging = require('../../../common/logging'),
config = require('../../../common/config'),
_ = require('underscore');
var path = require('path'),
fs = require('fs'),
async = require('async'),
chai = require('chai');
//var log = logging.getLogger(process.env.PKGCLOUD_LOG_LEVEL || 'debug');
var expect = chai.expect,
should = chai.should();
describe('DNS Record Integration Tests', function () {
var client, zoneName, adminEmail, apiUser, tempZone;
var recName, recType, recData, tempRec;
before(function (done) {
client = pkgcloud.providers.rackspace.dns.createClient(config.getConfig('rackspace', process.env['PKGCLOUD_TESTS_DEFAULT_USERNAME'])),
zoneName = 'that.test.computer',
adminEmail = 'test@test.com',
recName = 'this',
recData = '127.0.0.1',
recType = 'A';
client.createZone({name: zoneName, email: adminEmail}, function (err, zone) {
should.not.exist(err);
zone.should.be.an('object');
tempZone = zone;
done();
});
});
after(function (done) {
client.deleteZone(tempZone, {name: zoneName, email: adminEmail}, function (err) {
if (!err) {
console.log('\nDNS Zone teardown successful');
}
done();
});
});
describe('createRecord tests', function () {
it('createRecord is successful', function (done) {
client.createRecord(tempZone, {name: zoneName, data: recData, type: recType}, function (err, rec) {
should.not.exist(err);
rec.should.be.an('object');
tempRec = rec;
done();
});
});
it('createRecord should fail with same params', function (done) {
client.createRecord(tempZone, {name: zoneName, data: recData, type: recType}, function (err, rec) {
should.not.exist(rec);
err.should.be.an('object');
done();
});
});
});
describe('updateRecord tests', function () {
it('updateRecord should successfully modify Record', function (done) {
tempRec.data = '192.168.0.1';
client.updateRecord(tempZone, tempRec, function (err) {
if(err) throw err;
done();
});
});
it('updateRecord should fail', function (done) {
tempRec.data = '0';
client.updateRecord(tempZone, tempRec, function (err) {
should.exist(err);
err.should.be.an('object');
done();
});
});
});
describe('getRecord tests', function () {
it('getRecord should retrieve correct record', function (done) {
client.getRecord(tempZone, tempRec.id, function (err, rec) {
rec.id.should.equal(tempRec.id);
should.not.exist(err);
done();
});
});
it('getRecord should fail not found', function (done) {
client.getRecord(tempZone, 'AW-01010', function (err, rec) {
err.should.be.an('object');
should.not.exist(rec);
done();
});
});
});
});