|
@@ -392,82 +392,88 @@ describe('File API Integration Tests', () => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // describe('POST /api/v1/files/multipart-complete', () => {
|
|
|
|
|
- // it('should complete multipart upload successfully', async () => {
|
|
|
|
|
- // const mockCompleteData = {
|
|
|
|
|
- // uploadId: 'upload-123',
|
|
|
|
|
- // bucket: 'd8dai',
|
|
|
|
|
- // key: '1/test-file.zip',
|
|
|
|
|
- // parts: [
|
|
|
|
|
- // { partNumber: 1, etag: 'etag1' },
|
|
|
|
|
- // { partNumber: 2, etag: 'etag2' }
|
|
|
|
|
- // ]
|
|
|
|
|
- // };
|
|
|
|
|
|
|
+ describe('POST /api/v1/files/multipart-complete', () => {
|
|
|
|
|
+ it('should complete multipart upload successfully', async () => {
|
|
|
|
|
+ const mockCompleteData = {
|
|
|
|
|
+ uploadId: 'upload-123',
|
|
|
|
|
+ bucket: 'd8dai',
|
|
|
|
|
+ key: '1/test-file.zip',
|
|
|
|
|
+ parts: [
|
|
|
|
|
+ { partNumber: 1, etag: 'etag1' },
|
|
|
|
|
+ { partNumber: 2, etag: 'etag2' }
|
|
|
|
|
+ ]
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- // const mockResponse = {
|
|
|
|
|
- // fileId: 1,
|
|
|
|
|
- // url: 'https://minio.example.com/file.zip',
|
|
|
|
|
- // key: '1/test-file.zip',
|
|
|
|
|
- // size: 2048
|
|
|
|
|
- // };
|
|
|
|
|
|
|
+ const mockResponse = {
|
|
|
|
|
+ fileId: 1,
|
|
|
|
|
+ url: 'https://minio.example.com/file.zip',
|
|
|
|
|
+ key: '1/test-file.zip',
|
|
|
|
|
+ size: 2048
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- // vi.mocked(mockFileService.completeMultipartUpload).mockResolvedValue(mockResponse);
|
|
|
|
|
|
|
+ const mockCompleteMultipartUpload = vi.fn().mockResolvedValue(mockResponse);
|
|
|
|
|
+ vi.mocked(FileService).mockImplementation(() => ({
|
|
|
|
|
+ completeMultipartUpload: mockCompleteMultipartUpload
|
|
|
|
|
+ } as unknown as FileService));
|
|
|
|
|
|
|
|
- // const response = await client.files['multipart-complete'].$post({
|
|
|
|
|
- // json: mockCompleteData
|
|
|
|
|
- // },
|
|
|
|
|
- // {
|
|
|
|
|
- // headers: {
|
|
|
|
|
- // 'Authorization': 'Bearer test-token'
|
|
|
|
|
- // }
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ const response = await client.files['multipart-complete'].$post({
|
|
|
|
|
+ json: mockCompleteData
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': 'Bearer test-token'
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- // expect(response.status).toBe(200);
|
|
|
|
|
- // const result = await response.json();
|
|
|
|
|
- // expect(result).toEqual(mockResponse);
|
|
|
|
|
- // expect(mockFileService.completeMultipartUpload).toHaveBeenCalledWith(mockCompleteData);
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+ const result = await response.json();
|
|
|
|
|
+ expect(result).toEqual(mockResponse);
|
|
|
|
|
+ expect(mockCompleteMultipartUpload).toHaveBeenCalledWith(mockCompleteData);
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- // it('should validate complete multipart request data', async () => {
|
|
|
|
|
- // const invalidData = {
|
|
|
|
|
- // uploadId: 'upload-123',
|
|
|
|
|
- // // Missing required fields: bucket, key, parts
|
|
|
|
|
- // };
|
|
|
|
|
|
|
+ it('should validate complete multipart request data', async () => {
|
|
|
|
|
+ const invalidData = {
|
|
|
|
|
+ uploadId: 'upload-123',
|
|
|
|
|
+ // Missing required fields: bucket, key, parts
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- // const response = await client.files['multipart-complete'].$post({
|
|
|
|
|
- // json: invalidData
|
|
|
|
|
- // },
|
|
|
|
|
- // {
|
|
|
|
|
- // headers: {
|
|
|
|
|
- // 'Authorization': 'Bearer test-token'
|
|
|
|
|
- // }
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ const response = await client.files['multipart-complete'].$post({
|
|
|
|
|
+ json: invalidData as any
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': 'Bearer test-token'
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- // expect(response.status).toBe(400);
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ expect(response.status).toBe(400);
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- // it('should handle completion errors', async () => {
|
|
|
|
|
- // const completeData = {
|
|
|
|
|
- // uploadId: 'upload-123',
|
|
|
|
|
- // bucket: 'd8dai',
|
|
|
|
|
- // key: '1/test-file.zip',
|
|
|
|
|
- // parts: [{ partNumber: 1, etag: 'etag1' }]
|
|
|
|
|
- // };
|
|
|
|
|
|
|
+ it('should handle completion errors', async () => {
|
|
|
|
|
+ const completeData = {
|
|
|
|
|
+ uploadId: 'upload-123',
|
|
|
|
|
+ bucket: 'd8dai',
|
|
|
|
|
+ key: '1/test-file.zip',
|
|
|
|
|
+ parts: [{ partNumber: 1, etag: 'etag1' }]
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- // vi.mocked(mockFileService.completeMultipartUpload).mockRejectedValue(new Error('Completion failed'));
|
|
|
|
|
|
|
+ const mockCompleteMultipartUpload = vi.fn().mockRejectedValue(new Error('Completion failed'));
|
|
|
|
|
+ vi.mocked(FileService).mockImplementation(() => ({
|
|
|
|
|
+ completeMultipartUpload: mockCompleteMultipartUpload
|
|
|
|
|
+ } as unknown as FileService));
|
|
|
|
|
|
|
|
- // const response = await client.files['multipart-complete'].$post({
|
|
|
|
|
- // json: completeData
|
|
|
|
|
- // },
|
|
|
|
|
- // {
|
|
|
|
|
- // headers: {
|
|
|
|
|
- // 'Authorization': 'Bearer test-token'
|
|
|
|
|
- // }
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ const response = await client.files['multipart-complete'].$post({
|
|
|
|
|
+ json: completeData
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': 'Bearer test-token'
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- // expect(response.status).toBe(500);
|
|
|
|
|
- // });
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ expect(response.status).toBe(500);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
// describe('CRUD Operations', () => {
|
|
// describe('CRUD Operations', () => {
|
|
|
// it('should list files successfully', async () => {
|
|
// it('should list files successfully', async () => {
|