fix(media): handle missing path parameter and improve error logging
- Updated `getFile` method to validate `path` query parameter. - Added improved logging for file retrieval errors. - Updated test cases to cover scenarios with missing `path`.
This commit is contained in:
@@ -49,6 +49,13 @@ describe("MediaController", () => {
|
||||
expect(stream.pipe).toHaveBeenCalledWith(res);
|
||||
});
|
||||
|
||||
it("should throw NotFoundException if path is missing", async () => {
|
||||
const res = {} as unknown as Response;
|
||||
await expect(controller.getFile("", res)).rejects.toThrow(
|
||||
NotFoundException,
|
||||
);
|
||||
});
|
||||
|
||||
it("should throw NotFoundException if file is not found", async () => {
|
||||
mockS3Service.getFileInfo.mockRejectedValue(new Error("Not found"));
|
||||
const res = {} as unknown as Response;
|
||||
|
||||
Reference in New Issue
Block a user