Skip to content

Commit 4e20ded

Browse files
committed
feat: implement file delete http handler
1 parent 1a663c3 commit 4e20ded

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/file.http.router.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,9 @@ router.put(
290290
router.delete(
291291
PATH_SINGLE,
292292
deleteFor({
293-
soft: true,
294293
del: (options, done) => {
295294
const { File } = createModels();
296-
return File.del(options, done);
295+
return File.unlink(get(options, '_id'), done);
297296
},
298297
})
299298
);

test/file.http.spec.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,26 @@ describe('HTTP API', () => {
9393

9494
it.skip('should handle HTTP PATCH on /files/:bucket/:id', done => done());
9595
it.skip('should handle HTTP PUT on /files/:bucket/:id', done => done());
96-
it.skip('should handle HTTP DELETE on /files/:bucket/:id', done => done());
96+
97+
it('should handle HTTP DELETE on /files/:bucket/:id', done => {
98+
const { testDelete } = testRouter(options, fileRouter);
99+
const params = { bucket: 'files', id: file._id };
100+
testDelete(params)
101+
.expect('Content-Type', /json/)
102+
.expect(200, (error, { body }) => {
103+
console.log(body);
104+
expect(error).to.not.exist;
105+
expect(body).to.exist;
106+
expect(body._id).to.exist.and.be.eql(file._id);
107+
expect(body.filename).to.exist.and.be.eql(file.filename);
108+
expect(body.contentType).to.exist.and.be.eql(file.contentType);
109+
expect(body.length).to.exist.and.be.eql(file.length);
110+
expect(body.chunkSize).to.exist.and.be.eql(file.chunkSize);
111+
expect(body.uploadDate).to.exist.and.be.eql(file.uploadDate);
112+
expect(body.md5).to.exist.and.be.eql(file.md5);
113+
done(error, body);
114+
});
115+
});
97116

98117
after(() => clearHttp());
99118
after(done => clearDatabase(done));

0 commit comments

Comments
 (0)