-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathcopy.test.ts
More file actions
58 lines (54 loc) · 1.69 KB
/
Copy pathcopy.test.ts
File metadata and controls
58 lines (54 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { copy as advancedCopy } from '../../../src/internals';
import { copy as copyInternal } from '../../../src/providers/s3/apis/internal/copy';
import { createMockAmplifyContext } from '../../testUtils/mockAmplifyContext';
jest.mock('../../../src/providers/s3/apis/internal/copy');
const mockedCopyInternal = jest.mocked(copyInternal);
const mockCtx = createMockAmplifyContext();
describe('copy (internals)', () => {
beforeEach(() => {
jest.clearAllMocks();
mockedCopyInternal.mockResolvedValue({
path: 'output/path/to/mock/object',
});
});
it('should pass advanced option locationCredentialsProvider to internal list', async () => {
const customEndpoint = 's3.dualstack.us-east-2.amazonaws.com';
const locationCredentialsProvider = async () => ({
credentials: {
accessKeyId: 'akid',
secretAccessKey: 'secret',
sessionToken: 'token',
expiration: new Date(),
},
});
const copyInputWithAdvancedOptions = {
source: {
path: 'path/to/object',
bucket: 'bucket',
eTag: 'eTag',
notModifiedSince: new Date(),
expectedBucketOwner: '012345678901',
},
destination: {
path: 'path/to/object',
bucket: 'bucket',
expectedBucketOwner: '212345678901',
},
options: {
locationCredentialsProvider,
customEndpoint,
},
};
const result = await advancedCopy(mockCtx, copyInputWithAdvancedOptions);
expect(mockedCopyInternal).toHaveBeenCalledTimes(1);
expect(mockedCopyInternal).toHaveBeenCalledWith(
mockCtx,
copyInputWithAdvancedOptions,
);
expect(result).toEqual({
path: 'output/path/to/mock/object',
});
});
});