server: tests: match EACCES code only

This commit is contained in:
Jesse Chan
2020-12-27 23:38:16 +08:00
parent 9bced5a580
commit 3a2fef83ad
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -106,7 +106,7 @@ describe('POST /api/torrents/add-urls', () => {
.end((err, res) => {
if (err) done(err);
expect(res.body).toEqual({code: 'EACCES'});
expect(res.body).toMatchObject({code: 'EACCES'});
done();
});
@@ -213,7 +213,7 @@ describe('POST /api/torrents/add-files', () => {
.end((err, res) => {
if (err) done(err);
expect(res.body).toEqual({code: 'EACCES'});
expect(res.body).toMatchObject({code: 'EACCES'});
done();
});
+2 -2
View File
@@ -5,13 +5,13 @@ import path from 'path';
import config from '../../config';
export const accessDeniedError = () => {
const error = new Error() as NodeJS.ErrnoException;
const error = new Error('Permission denied') as NodeJS.ErrnoException;
error.code = 'EACCES';
return error;
};
export const fileNotFoundError = () => {
const error = new Error() as NodeJS.ErrnoException;
const error = new Error('No such file or directory') as NodeJS.ErrnoException;
error.code = 'ENOENT';
return error;
};