2024-09-12 09:07:18 -07:00
|
|
|
import Container from 'typedi';
|
|
|
|
|
2023-07-13 01:14:48 -07:00
|
|
|
import { NODE_PACKAGE_PREFIX } from '@/constants';
|
2024-08-27 07:44:32 -07:00
|
|
|
import { InstalledPackages } from '@/databases/entities/installed-packages';
|
|
|
|
import { InstalledNodesRepository } from '@/databases/repositories/installed-nodes.repository';
|
|
|
|
import { InstalledPackagesRepository } from '@/databases/repositories/installed-packages.repository';
|
2024-09-12 09:07:18 -07:00
|
|
|
|
|
|
|
import { COMMUNITY_NODE_VERSION, COMMUNITY_PACKAGE_VERSION } from '../constants';
|
|
|
|
import { randomName } from '../random';
|
2023-07-13 01:14:48 -07:00
|
|
|
|
2023-09-01 06:13:19 -07:00
|
|
|
export const mockPackageName = () => NODE_PACKAGE_PREFIX + randomName();
|
|
|
|
|
|
|
|
export const mockPackage = () =>
|
|
|
|
Container.get(InstalledPackagesRepository).create({
|
|
|
|
packageName: mockPackageName(),
|
2023-07-13 01:14:48 -07:00
|
|
|
installedVersion: COMMUNITY_PACKAGE_VERSION.CURRENT,
|
2023-09-01 06:13:19 -07:00
|
|
|
installedNodes: [],
|
|
|
|
});
|
2023-07-13 01:14:48 -07:00
|
|
|
|
2023-09-01 06:13:19 -07:00
|
|
|
export const mockNode = (packageName: string) => {
|
2023-07-13 01:14:48 -07:00
|
|
|
const nodeName = randomName();
|
2023-09-01 06:13:19 -07:00
|
|
|
|
|
|
|
return Container.get(InstalledNodesRepository).create({
|
2023-07-13 01:14:48 -07:00
|
|
|
name: nodeName,
|
|
|
|
type: nodeName,
|
2024-09-12 02:14:03 -07:00
|
|
|
latestVersion: COMMUNITY_NODE_VERSION.CURRENT,
|
2023-09-01 06:13:19 -07:00
|
|
|
package: { packageName },
|
|
|
|
});
|
|
|
|
};
|
2023-07-13 01:14:48 -07:00
|
|
|
|
|
|
|
export const emptyPackage = async () => {
|
|
|
|
const installedPackage = new InstalledPackages();
|
|
|
|
installedPackage.installedNodes = [];
|
|
|
|
return installedPackage;
|
|
|
|
};
|
2023-09-01 06:13:19 -07:00
|
|
|
|
|
|
|
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];
|
|
|
|
}
|