Skip to content

Commit 984b620

Browse files
author
Devendra
committed
clean up after node tests
1 parent 0fe23c4 commit 984b620

1 file changed

Lines changed: 39 additions & 5 deletions

File tree

node.js/tests/dstest.js

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ var pubnub = PUBNUB({
88
build_u : true
99
});
1010

11+
var pubnub_random_objects = [];
12+
var pubnub_pam_random_objects = [];
13+
1114
var pubnub_pam = PUBNUB({
1215
write_key : "ds-pam",
1316
read_key : "ds-pam",
@@ -49,16 +52,33 @@ function pn_random(){
4952
describe('Pubnub', function() {
5053

5154
this.timeout(40000);
55+
56+
57+
after(function(){
58+
for (var i in pubnub_random_objects) {
59+
var id = pubnub_random_objects[i];
60+
pubnub.remove(id);
61+
}
62+
for (var i in pubnub_pam_random_objects) {
63+
var id = pubnub_pam_random_objects[i];
64+
pubnub_pam.remove(id);
65+
}
66+
})
67+
5268
describe("#PAM", function(){
5369
describe("grant()", function(){
5470
it("should be able to grant permission on object", function(done) {
5571
var object_id = pn_random();
72+
pubnub_random_objects.push(object_id);
5673
pubnub_pam.grant({
5774
'object_id' : object_id,
5875
'read' : true,
5976
'write' : true,
6077
'auth_key' : 'abcd',
6178
'success' : function(r) {
79+
80+
pubnub_pam_random_objects.push(object_id + '.a');
81+
6282
pubnub_pam.merge(object_id + '.a', "abcd", {
6383
'success' : function(r){
6484
assert.ok(true);
@@ -86,9 +106,13 @@ describe('Pubnub', function() {
86106
describe("revoke()", function(){
87107
it("should be able to revoke permission on object", function(done) {
88108
var object_id = pn_random();
109+
pubnub_random_objects.push(object_id);
89110
pubnub_pam.revoke({
90111
'object_id' : object_id,
91112
'success' : function(r) {
113+
114+
pubnub_pam_random_objects.push(object_id + '.a');
115+
92116
pubnub_pam.merge(object_id + '.a', "abcd", {
93117
'error' : function(r){
94118
assert.ok(true);
@@ -121,6 +145,8 @@ describe('Pubnub', function() {
121145
var location = seed + 'office.occupants';
122146
var occupants_list = ["a", "b", "c", "d"];
123147

148+
pubnub_random_objects.push(location);
149+
124150
pubnub.merge(location, occupants_list, {
125151
'success' : function(r) {
126152
var occupants = pubnub.sync(location);
@@ -426,7 +452,7 @@ describe('Pubnub', function() {
426452
}
427453

428454
};
429-
455+
pubnub_random_objects.push(seed);
430456
pubnub.merge(
431457
seed,
432458
data, {
@@ -499,6 +525,7 @@ describe('Pubnub', function() {
499525
});
500526

501527
ref.on.ready(function(r){
528+
pubnub_random_objects.push(seed + 'a.b.c.d');
502529
ref.merge(seed);
503530
})
504531

@@ -515,6 +542,7 @@ describe('Pubnub', function() {
515542
});
516543

517544
ref.on.ready(function(r){
545+
pubnub_random_objects.push(seed + 'a.b.c.d');
518546
pubnub.merge(
519547
seed + 'a.b.c.d',
520548
seed, {
@@ -540,6 +568,7 @@ describe('Pubnub', function() {
540568
});
541569

542570
ref.on.ready(function(r){
571+
pubnub_random_objects.push(seed + '.a.b.c.d');
543572
pubnub.merge(
544573
seed + '.a.b.c.d',
545574
seed, {
@@ -589,7 +618,7 @@ describe('Pubnub', function() {
589618
}
590619

591620
};
592-
621+
pubnub_random_objects.push(seed);
593622
pubnub.merge(
594623
seed,
595624
data, {
@@ -657,6 +686,7 @@ describe('Pubnub', function() {
657686

658687
r6.on.ready(function(ref){
659688
deepEqual(ref.value(), val1);
689+
pubnub_random_objects.push(seed + '.a.b.c.d.e.f.g.h.i.j.k.l');
660690
r6.merge(val2);
661691
start();
662692
});
@@ -718,6 +748,7 @@ describe('Pubnub', function() {
718748
});
719749

720750
ref.on.ready(function(r){
751+
pubnub_random_objects.push(seed + 'a.b.c.d');
721752
ref.merge(seed + 2);
722753
})
723754

@@ -759,7 +790,7 @@ describe('Pubnub', function() {
759790
}
760791

761792
};
762-
793+
pubnub_random_objects.push(seed);
763794
pubnub.merge(
764795
seed,
765796
data, {
@@ -848,6 +879,7 @@ describe('Pubnub', function() {
848879

849880
r6.on.ready(function(ref){
850881
deepEqual(ref.value(), val1);
882+
pubnub_random_objects.push(val2);
851883
r6.merge(val2);
852884
start();
853885
});
@@ -890,6 +922,7 @@ describe('Pubnub', function() {
890922
});
891923

892924
ref.on.ready(function(r){
925+
pubnub_random_objects.push(seed + 3);
893926
ref.merge(seed + 3)
894927
})
895928

@@ -930,7 +963,7 @@ describe('Pubnub', function() {
930963
}
931964

932965
};
933-
966+
pubnub_random_objects.push(seed);
934967
pubnub.merge(
935968
seed,
936969
data, {
@@ -973,8 +1006,9 @@ describe('Pubnub', function() {
9731006
});
9741007

9751008
var r2 = pubnub.sync(seed + '.a.b');
1009+
pubnub_random_objects.push(seed + '.a.b');
9761010

977-
r2.on.ready(function(ref){
1011+
r2.on.ready(function(ref){
9781012
assert.deepEqual(ref.value('c.d.e.f.g.h.i.j.k.l'), val1);
9791013
});
9801014
r2.on.merge(function(ref){

0 commit comments

Comments
 (0)