Skip to content

Commit b76a9f2

Browse files
author
Nicola Greco
committed
Merge pull request #176 from linkeddata/dz_test_cleanup_files
Add test file cleanup before() and after() tests
2 parents ed7e845 + 598c7b9 commit b76a9f2

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

‎test/acl.js‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ describe('ACL HTTP', function() {
135135
});
136136
})
137137
describe("with defaultForNew in parent path", function () {
138+
before(function() {
139+
rm('/acl/write-acl/empty-acl/another-empty-folder/test-file.acl');
140+
rm('/acl/write-acl/empty-acl/test-folder/test-file');
141+
rm('/acl/write-acl/empty-acl/test-file');
142+
rm('/acl/write-acl/test-file');
143+
rm('/acl/write-acl/test-file.acl');
144+
});
145+
138146
it("should fail to create a container", function(done) {
139147
var options = createOptions('/acl/write-acl/empty-acl/test-folder/', 'user1');
140148
options.body = "";
@@ -219,10 +227,22 @@ describe('ACL HTTP', function() {
219227
done();
220228
});
221229
});
230+
231+
after(function() {
232+
rm('/acl/write-acl/empty-acl/another-empty-folder/test-file.acl');
233+
rm('/acl/write-acl/empty-acl/test-folder/test-file');
234+
rm('/acl/write-acl/empty-acl/test-file');
235+
rm('/acl/write-acl/test-file');
236+
rm('/acl/write-acl/test-file.acl');
237+
});
222238
})
223239
});
224240

225241
describe("Origin", function() {
242+
before(function () {
243+
rm('acl/origin/test-folder/.acl');
244+
});
245+
226246
it("Should PUT new ACL file", function(done) {
227247
var options = createOptions('/acl/origin/test-folder/.acl', 'user1');
228248
options.headers = {
@@ -316,6 +336,10 @@ describe('ACL HTTP', function() {
316336
done();
317337
});
318338
});
339+
340+
after(function () {
341+
rm('acl/origin/test-folder/.acl');
342+
});
319343
});
320344

321345
describe.skip("Owner-only", function() {
@@ -849,6 +873,11 @@ describe('ACL HTTP', function() {
849873
});
850874

851875
describe("defaultForNew", function() {
876+
before(function() {
877+
rm('/acl/write-acl/default-for-new/.acl');
878+
rm('/acl/write-acl/default-for-new/test-file.ttl');
879+
});
880+
852881
var body = "<#Owner>\n" +
853882
" <http://www.w3.org/ns/auth/acl#accessTo> <./>;\n" +
854883
" <http://www.w3.org/ns/auth/acl#agent> <" + user1 + ">;\n" +
@@ -947,6 +976,11 @@ describe('ACL HTTP', function() {
947976
done();
948977
});
949978
});
979+
980+
after(function() {
981+
rm('/acl/write-acl/default-for-new/.acl');
982+
rm('/acl/write-acl/default-for-new/test-file.ttl');
983+
});
950984
});
951985

952986
describe("WebID delegation tests", function() {
@@ -1001,4 +1035,4 @@ describe('ACL HTTP', function() {
10011035
}
10021036
});
10031037
});
1004-
});
1038+
});

‎test/test-utils.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ var fs = require('fs');
22
var fsExtra = require('fs-extra');
33

44
exports.rm = function (file) {
5-
return fs.unlinkSync(__dirname + '/resources/' + file);
5+
try {
6+
return fs.unlinkSync(__dirname + '/resources/' + file);
7+
} catch (e) {
8+
// do nothing, suppress "Error: ENOENT, no such file or directory" errors
9+
}
10+
611
};
712

813
exports.write = function (text, file) {

0 commit comments

Comments
 (0)