|
| 1 | +import { |
| 2 | + CloudserverClient, |
| 3 | + MultipleBackendDeleteObjectInput, |
| 4 | + MultipleBackendDeleteObjectCommand, |
| 5 | + GetObjectInput, |
| 6 | + GetObjectCommand, |
| 7 | +} from '@scality/cloudserverclient'; |
| 8 | +import { createTestClient, testConfig } from './testSetup'; |
| 9 | + |
| 10 | +describe('CloudServer test error handling', () => { |
| 11 | + let client: CloudserverClient; |
| 12 | + |
| 13 | + beforeAll(() => { |
| 14 | + client = createTestClient(); |
| 15 | + }); |
| 16 | + |
| 17 | + it('should test xml parsing', async () => { |
| 18 | + // Run CloudServer with : S3VAULT=mem S3METADATA=mem S3DATA=mem REMOTE_MANAGEMENT_DISABLE=true yarn start |
| 19 | + try { |
| 20 | + const getInput: GetObjectInput = { |
| 21 | + Bucket: testConfig.bucketName, |
| 22 | + Key: 'notAKey', |
| 23 | + }; |
| 24 | + const getCommand = new GetObjectCommand(getInput); |
| 25 | + const getData = await client.send(getCommand); |
| 26 | + } catch (err: any) { |
| 27 | + console.log('Error:', err); |
| 28 | + console.log('Error name:', err.name); |
| 29 | + console.log('Error message:', err.message); |
| 30 | + console.log('Error code:', err.$metadata?.httpStatusCode); |
| 31 | + } |
| 32 | + }); |
| 33 | + |
| 34 | + it('should test html parsing', async () => { |
| 35 | + // Run CloudServer with : S3VAULT=mem S3METADATA=mem S3DATA=mem REMOTE_MANAGEMENT_DISABLE=true yarn start |
| 36 | + try { |
| 37 | + const deleteInput: MultipleBackendDeleteObjectInput = { |
| 38 | + Bucket: 'testConfig.bucketName', |
| 39 | + Key: 'notAKey', |
| 40 | + StorageClass: 'us-east-1', |
| 41 | + StorageType: 'file' |
| 42 | + }; |
| 43 | + const commandDelete = new MultipleBackendDeleteObjectCommand(deleteInput); |
| 44 | + const deleteResult = await client.send(commandDelete); |
| 45 | + } catch (err: any) { |
| 46 | + console.log('Error:', err); |
| 47 | + console.log('Error name:', err.name); |
| 48 | + console.log('Error message:', err.message); |
| 49 | + console.log('Error code:', err.$metadata?.httpStatusCode); |
| 50 | + } |
| 51 | + }); |
| 52 | +}); |
0 commit comments