Skip to content

Commit c90f3d3

Browse files
author
Narine C
authored
Merge pull request #28 from csync/tgb/26-Add-Tests-Wildcard-Delete
Tgb/26 add tests wildcard delete
2 parents 38901a1 + 8450c5d commit c90f3d3

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

‎README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ Note: The ACL is inherited from its closest existing ancestor, up to the root ke
146146
## Deleting a key
147147

148148
myKey.delete();
149-
149+
150+
Note: A delete key can contain any number of wildcards as well. For example, the key a.b would be deleted by `a.*`, but the key `a.b.c` would not because the wildcard only covers the second part of the key. The key `a.b.c` could be deleted by `a.*.*`, `a.b.*`, `a.*.c`, `*.*.c` or `*.*.*`. The key `*.*.*` would delete all keys of length 3. Wildcard deletes make a best effort to delete everything you have access to. If you do not delete anything, you will still get a successful return because the server succesfully deleted all nodes you had access to, even if none existed.
150151

151152
# License
152153
This library is licensed under Apache 2.0. Full license text is

‎test/integration/index.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('Integration Tests', function() {
4242
}
4343
}
4444

45-
this.timeout(10000);
45+
this.timeout(20000);
4646

4747
// MARK: - App tests
4848

@@ -455,6 +455,24 @@ describe('Integration Tests', function() {
455455
});
456456
});
457457

458+
it('should be able to delete on a wildcard', function(done) {
459+
460+
var app = csync(config);
461+
app.authenticate(provider, token);
462+
var uuidString = uuid.v4();
463+
var testKey = app.key(jsKey+".delete-asterisk-test."+uuidString+".a");
464+
var deleteKey = app.key(jsKey+".delete-asterisk-test."+uuidString+".*");
465+
var value = "testData";
466+
testKey.write(value).then(function(result){
467+
testKey.listen(function(error, value) {
468+
if(value.exists === false && error === null){
469+
done();
470+
}
471+
});
472+
deleteKey.delete();
473+
});
474+
});
475+
458476
});
459477

460478
// MARK: - Error cases
@@ -495,6 +513,19 @@ describe('Integration Tests', function() {
495513
});
496514
});
497515

516+
it('should not be able to write on a wildcard', function(done) {
517+
518+
var app = csync(config);
519+
app.authenticate(provider, token).then(function(authData){
520+
var writeKey = app.key(jsKey+".delete-asterisk-test."+uuid.v4()+".*");
521+
var value = "testData";
522+
writeKey.write(value).catch(function(error){
523+
expect(error.code).to.be.equal(csync.RequestError);
524+
done();
525+
});
526+
});
527+
});
528+
498529
});
499530

500531
});

0 commit comments

Comments
 (0)