Skip to content

Commit 58ae441

Browse files
comply with linter
ISSUE: CLDSRVCLT-2
1 parent 2f4231d commit 58ae441

File tree

7 files changed

+39
-41
lines changed

7 files changed

+39
-41
lines changed

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function createCustomErrorMiddleware() {
5050
message: result.Error?.Message,
5151
requestId: result.Error?.RequestId,
5252
};
53-
} catch (parseError) {
53+
} catch (_parseError) {
5454
return {
5555
code: null,
5656
message: 'Malformed XML error response',
@@ -90,7 +90,7 @@ export function createCustomErrorMiddleware() {
9090

9191
const htmlError: any = new CloudserverServiceException({
9292
name: `HTML ${response?.reason || 'Error'}`,
93-
message: message,
93+
message,
9494
$fault: statusCode >= 500 ? 'server' : 'client',
9595
$metadata: error.$metadata || {},
9696
$response: error.$response,

tests/testApis.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
BatchDeleteCommand,
1212
addContentLengthMiddleware
1313
} from '../src/index';
14-
import { S3Client, GetObjectCommand as s3getCommand } from '@aws-sdk/client-s3';
14+
import { S3Client, GetObjectCommand as S3getCommand } from '@aws-sdk/client-s3';
1515
import { createTestClient, testConfig } from './testSetup';
1616
import assert from 'assert';
1717

@@ -24,7 +24,7 @@ describe('CloudServer API Tests', () => {
2424
});
2525

2626
it('should test PutData', async () => {
27-
const command = new s3getCommand({
27+
const command = new S3getCommand({
2828
Bucket: testConfig.bucketName,
2929
Key: testConfig.objectKey,
3030
});
@@ -77,19 +77,19 @@ describe('CloudServer API Tests', () => {
7777
it('should test BatchDelete', async () => {
7878
const locations: BatchDeleteLocation[] = [
7979
{
80-
dataStoreName: "mem",
81-
key: "aaaa1",
80+
dataStoreName: 'mem',
81+
key: 'aaaa1',
8282
size: 8,
83-
dataStoreVersionId: "v1"
83+
dataStoreVersionId: 'v1'
8484
}
8585
];
8686
const batchDeleteInput: BatchDeleteInput = {
8787
Bucket: testConfig.bucketName,
8888
Key: testConfig.objectKey,
8989
IfUnmodifiedSince: new Date().toISOString(),
90-
StorageClass: "STANDARD",
91-
Tags: JSON.stringify({ "somekey": "test" }),
92-
ContentType: "application/octet-stream",
90+
StorageClass: 'STANDARD',
91+
Tags: JSON.stringify({ somekey: 'test' }),
92+
ContentType: 'application/octet-stream',
9393
Locations: locations
9494
};
9595

tests/testErrorHandling.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,8 @@ describe('CloudServer test error handling', () => {
4444
const commandDelete = new MultipleBackendDeleteObjectCommand(deleteInput);
4545
await client.send(commandDelete);
4646
} catch (err: any) {
47-
console.log('Error:', err);
48-
console.log('Error name:', err.name);
49-
console.log('Error message:', err.message);
50-
console.log('Error code:', err.$metadata?.httpStatusCode);
51-
console.log('Error rawBody:', err.rawBody);
47+
assert.strictEqual(err.name, 'NoSuchKey');
48+
assert.strictEqual(err.$metadata?.httpStatusCode, 404);
5249
}
5350
});
5451
});

tests/testIndexesApis.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ describe('CloudServer Indexes API Tests', () => {
2020
it('should test PutBucketIndexes', async () => {
2121
const indexData = JSON.stringify([
2222
{
23-
name: "testIndex1",
23+
name: 'testIndex1',
2424
keys: [
25-
{ order: 1, key: "metadata.userId" }
25+
{ order: 1, key: 'metadata.userId' }
2626
]
2727
}
2828
]);
@@ -48,9 +48,9 @@ describe('CloudServer Indexes API Tests', () => {
4848
it('should test DeleteBucketIndexes and verify deletion', async () => {
4949
const indexesToDelete = JSON.stringify([
5050
{
51-
name: "testIndex1",
51+
name: 'testIndex1',
5252
keys: [
53-
{ order: 1, key: "metadata.userId" }
53+
{ order: 1, key: 'metadata.userId' }
5454
]
5555
}
5656
]);

tests/testMetadataApis.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ describe('CloudServer Metadata API Tests', () => {
2929

3030
it('should test PutMetadata API', async () => {
3131
const metadataObj = {
32-
"content-length": 1000,
33-
"content-type": "text/plain",
34-
"x-amz-meta-custom": "test-valuee",
35-
"last-modified": new Date().toISOString(),
36-
"etag": "\"d41d8cd98f00b204e9800998ecf8427e\"",
37-
"x-amz-version-id": "null",
38-
"replicationInfo": {}
32+
'content-length': 1000,
33+
'content-type': 'text/plain',
34+
'x-amz-meta-custom': 'test-valuee',
35+
'last-modified': new Date().toISOString(),
36+
'etag': '"d41d8cd98f00b204e9800998ecf8427e"',
37+
'x-amz-version-id': 'null',
38+
'replicationInfo': {}
3939
};
4040

4141
const metadataString = JSON.stringify(metadataObj);

tests/testMultipleBackendApis.test.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ describe('CloudServer Multiple Backend API Tests', () => {
5656
'another-meta': 'another-value'
5757
}),
5858
Tags: JSON.stringify({
59-
'tag1': 'value1',
60-
'tag2': 'value2'
59+
tag1: 'value1',
60+
tag2: 'value2'
6161
}),
6262
StorageClass: 'us-east-1',
6363
StorageType: 'file',
@@ -76,7 +76,8 @@ describe('CloudServer Multiple Backend API Tests', () => {
7676
assert.ok(location.dataStoreETag, 'dataStoreETag should exist');
7777
assert.ok(
7878
location.dataStoreETag.includes(etag),
79-
`dataStoreETag should contain the original etag. Expected to include: ${etag}, got: ${location.dataStoreETag}`
79+
`dataStoreETag should contain the original etag.
80+
Expected to include: ${etag}, got: ${location.dataStoreETag}`
8081
);
8182

8283
const deleteInput: MultipleBackendDeleteObjectInput = {
@@ -97,7 +98,7 @@ describe('CloudServer Multiple Backend API Tests', () => {
9798
};
9899
const getCommand = new GetObjectCommand(getInput);
99100
const getData = await client.send(getCommand);
100-
const dataBody = await getData.Body.transformToString()
101+
const dataBody = await getData.Body.transformToString();
101102
const bodyBuffer = Buffer.from(dataBody);
102103
const contentMD5 = crypto.createHash('md5').update(bodyBuffer).digest('hex');
103104
const putInput: MultipleBackendPutObjectInput = {
@@ -111,8 +112,8 @@ describe('CloudServer Multiple Backend API Tests', () => {
111112
'another-meta': 'another-value'
112113
}),
113114
Tags: JSON.stringify({
114-
'tag1': 'value1',
115-
'tag2': 'value2'
115+
tag1: 'value1',
116+
tag2: 'value2'
116117
}),
117118
StorageClass: 'us-east-1',
118119
StorageType: 'file',
@@ -152,13 +153,13 @@ describe('CloudServer Multiple Backend API Tests', () => {
152153
StorageClass: 'us-east-1',
153154
StorageType: 'file',
154155
Tags: JSON.stringify({
155-
'Environment': 'Test',
156-
'Project': 'Cloudserver'
156+
Environment: 'Test',
157+
Project: 'Cloudserver'
157158
}),
158159
Body: tagData,
159160
DataStoreVersionId: 'v1',
160-
SourceBucket: "aBucket",
161-
ReplicationEndpointSite: "aVal"
161+
SourceBucket: 'aBucket',
162+
ReplicationEndpointSite: 'aVal'
162163
};
163164
const putTaggingCommand = new MultipleBackendPutObjectTaggingCommand(putTaggingInput);
164165
const putTaggingResult = await client.send(putTaggingCommand);

tests/testRaftApis.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ describe('CloudServer Raft API Tests', () => {
2828
};
2929
const getRaftIdCommand = new GetRaftIdCommand(getRaftIdInput);
3030
const raftIdData = await client.send(getRaftIdCommand);
31-
assert.strictEqual(raftIdData.RaftId, '1')
31+
assert.strictEqual(raftIdData.RaftId, '1');
3232
});
3333

3434
it('should test GetRaftBuckets API', async () => {
3535
// Run Cloudserver with : S3VAULT=mem S3METADATA=mongodb S3DATA=mem REMOTE_MANAGEMENT_DISABLE=true yarn start
3636
const getRaftBucketsInput: GetRaftBucketsInput = {
37-
LogId: "1",
37+
LogId: '1',
3838
};
3939
const getRaftBucketsCommand = new GetRaftBucketsCommand(getRaftBucketsInput);
4040
const raftBucketsData = await client.send(getRaftBucketsCommand);
4141
const raftBucketsDataAny: any = raftBucketsData.Buckets as any;
42-
assert.ok(raftBucketsDataAny.length >= 1)
42+
assert.ok(raftBucketsDataAny.length >= 1);
4343
});
4444

4545
it('should test GetRaftLog API', async () => {
@@ -58,7 +58,7 @@ describe('CloudServer Raft API Tests', () => {
5858
}
5959
}
6060
const getRaftLogInput: GetRaftLogInput = {
61-
LogId: "1",
61+
LogId: '1',
6262
Begin: 1,
6363
Limit: 2,
6464
};
@@ -86,7 +86,7 @@ describe('CloudServer Raft API Tests', () => {
8686
headerParser.on('data', (info: any) => {
8787
recordStream.removeAllListeners('error');
8888
return done(null, {
89-
info: info,
89+
info,
9090
log: recordStream,
9191
});
9292
});

0 commit comments

Comments
 (0)