mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-27 21:49:41 -08:00
6d6e2488c6
Depends on: #7092 | Story: [PAY-768](https://linear.app/n8n/issue/PAY-768) This PR: - Generalizes the `IBinaryDataManager` interface. - Adjusts `Filesystem.ts` to satisfy the interface. - Sets up an S3 client stub to be filled in in the next PR. - Turns `BinaryDataManager` into an injectable service. - Adjusts the config schema and adds new validators. Note that the PR looks large but all the main changes are in `packages/core/src/binaryData`. Out of scope: - `BinaryDataManager` (now `BinaryDataService`) and `Filesystem.ts` (now `fs.client.ts`) were slightly refactored for maintainability, but fully overhauling them is **not** the focus of this PR, which is meant to clear the way for the S3 implementation. Future improvements for these two should include setting up a backwards-compatible dir structure that makes it easier to locate binary data files to delete, removing duplication, simplifying cloning methods, using integers for binary data size instead of `prettyBytes()`, writing tests for existing binary data logic, etc. --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import nock from 'nock';
|
|
import { getWorkflowFilenames, initBinaryDataService, testWorkflows } from '@test/nodes/Helpers';
|
|
|
|
const workflows = getWorkflowFilenames(__dirname);
|
|
|
|
describe('Test S3 V1 Node', () => {
|
|
describe('File Upload', () => {
|
|
let mock: nock.Scope;
|
|
const now = 1683028800000;
|
|
|
|
beforeAll(async () => {
|
|
jest.useFakeTimers({ doNotFake: ['nextTick'], now });
|
|
|
|
await initBinaryDataService();
|
|
|
|
nock.disableNetConnect();
|
|
mock = nock('https://bucket.s3.eu-central-1.amazonaws.com');
|
|
});
|
|
|
|
beforeEach(async () => {
|
|
mock.get('/?location').reply(
|
|
200,
|
|
`<?xml version="1.0" encoding="UTF-8"?>
|
|
<LocationConstraint>
|
|
<LocationConstraint>eu-central-1</LocationConstraint>
|
|
</LocationConstraint>`,
|
|
{
|
|
'content-type': 'application/xml',
|
|
},
|
|
);
|
|
|
|
mock
|
|
.put('/binary.json')
|
|
.matchHeader(
|
|
'X-Amz-Content-Sha256',
|
|
'e43abcf3375244839c012f9633f95862d232a95b00d5bc7348b3098b9fed7f32',
|
|
)
|
|
.once()
|
|
.reply(200, { success: true });
|
|
});
|
|
|
|
afterAll(() => {
|
|
nock.restore();
|
|
});
|
|
|
|
testWorkflows(workflows);
|
|
});
|
|
});
|