mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Move webhook DB access to repository (no-changelog) (#6706)
* refactor(core): Move webhook DB access to repository (no-changelog) * make sure `DataSource` is initialized before it's dependencies at some point I hope to replace `DataSource` with a custom `DatabaseConnection` service class that can then disconnect and reconnect from DB without having to update all repositories. --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -24,6 +24,7 @@ import { mockInstance } from '../integration/shared/utils/';
|
||||
import { Push } from '@/push';
|
||||
import { ActiveExecutions } from '@/ActiveExecutions';
|
||||
import { NodeTypes } from '@/NodeTypes';
|
||||
import type { WebhookRepository } from '@/databases/repositories';
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
@@ -139,6 +140,7 @@ const workflowExecuteAdditionalDataExecuteErrorWorkflowSpy = jest.spyOn(
|
||||
describe('ActiveWorkflowRunner', () => {
|
||||
let externalHooks: ExternalHooks;
|
||||
let activeWorkflowRunner: ActiveWorkflowRunner;
|
||||
let webhookRepository = mock<WebhookRepository>();
|
||||
|
||||
beforeAll(async () => {
|
||||
LoggerProxy.init(getLogger());
|
||||
@@ -160,6 +162,7 @@ describe('ActiveWorkflowRunner', () => {
|
||||
new ActiveExecutions(),
|
||||
externalHooks,
|
||||
Container.get(NodeTypes),
|
||||
webhookRepository,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -174,7 +177,7 @@ describe('ActiveWorkflowRunner', () => {
|
||||
await activeWorkflowRunner.init();
|
||||
expect(await activeWorkflowRunner.getActiveWorkflows()).toHaveLength(0);
|
||||
expect(mocked(Db.collections.Workflow.find)).toHaveBeenCalled();
|
||||
expect(mocked(Db.collections.Webhook.clear)).toHaveBeenCalled();
|
||||
expect(mocked(webhookRepository.clear)).toHaveBeenCalled();
|
||||
expect(externalHooks.run).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
@@ -185,7 +188,7 @@ describe('ActiveWorkflowRunner', () => {
|
||||
databaseActiveWorkflowsCount,
|
||||
);
|
||||
expect(mocked(Db.collections.Workflow.find)).toHaveBeenCalled();
|
||||
expect(mocked(Db.collections.Webhook.clear)).toHaveBeenCalled();
|
||||
expect(mocked(webhookRepository.clear)).toHaveBeenCalled();
|
||||
expect(externalHooks.run).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user