first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { randomName } from '@n8n/backend-test-utils';
|
||||
import { Container } from '@n8n/di';
|
||||
|
||||
import { NODE_PACKAGE_PREFIX } from '@/constants';
|
||||
import { InstalledNodesRepository } from '@/modules/community-packages/installed-nodes.repository';
|
||||
import { InstalledPackages } from '@/modules/community-packages/installed-packages.entity';
|
||||
import { InstalledPackagesRepository } from '@/modules/community-packages/installed-packages.repository';
|
||||
|
||||
import { COMMUNITY_NODE_VERSION, COMMUNITY_PACKAGE_VERSION } from '../constants';
|
||||
|
||||
export const mockPackageName = () => NODE_PACKAGE_PREFIX + randomName();
|
||||
|
||||
export const mockPackage = () =>
|
||||
Container.get(InstalledPackagesRepository).create({
|
||||
packageName: mockPackageName(),
|
||||
installedVersion: COMMUNITY_PACKAGE_VERSION.CURRENT,
|
||||
installedNodes: [],
|
||||
});
|
||||
|
||||
export const mockNode = (packageName: string) => {
|
||||
const nodeName = randomName();
|
||||
|
||||
return Container.get(InstalledNodesRepository).create({
|
||||
name: nodeName,
|
||||
type: `${packageName}.${nodeName}`,
|
||||
latestVersion: COMMUNITY_NODE_VERSION.CURRENT,
|
||||
package: { packageName },
|
||||
});
|
||||
};
|
||||
|
||||
export const emptyPackage = async () => {
|
||||
const installedPackage = new InstalledPackages();
|
||||
installedPackage.installedNodes = [];
|
||||
return installedPackage;
|
||||
};
|
||||
|
||||
export function mockPackagePair(): InstalledPackages[] {
|
||||
const pkgA = mockPackage();
|
||||
const nodeA = mockNode(pkgA.packageName);
|
||||
pkgA.installedNodes = [nodeA];
|
||||
|
||||
const pkgB = mockPackage();
|
||||
const nodeB1 = mockNode(pkgB.packageName);
|
||||
const nodeB2 = mockNode(pkgB.packageName);
|
||||
pkgB.installedNodes = [nodeB1, nodeB2];
|
||||
|
||||
return [pkgA, pkgB];
|
||||
}
|
||||
Reference in New Issue
Block a user