export async function testRun(id: string, agentPs: PythonScript, action: PSAction): Promise<void> {
  if (action === PSAction.affectedSoftware) {
    const affectedSoftware = (await vulnerabilityService.getVulnerability(id)).map((element) => new AgentAffectedSoftware(element));
    const affectedSoftwareAgentPs = agentPs.data.affectedSoftware ? agentPs.data.affectedSoftware.map((element) => new AgentAffectedSoftware(element)) : [];

    expect(affectedSoftwareAgentPs, 'affectedSoftware').toEqual(affectedSoftware);
  } else if (action === PSAction.agent) {
    const agent = (await storageHelper.getAgentList()).filter((element) => element.id === id).filter(Boolean)[0];
    const agentNameSplit = agent.name.split('.');
    const os = await syscollectorService.getOs(id);

    expect(agentPs.id, 'id').toEqual(agent.id);
    expect(agentPs.data.domain_workgroup, 'domain_workgroup').toEqual(agentNameSplit[1] ? agent.name.replace(`${agentNameSplit[0]}.`, '') : undefined);
    expect(agentPs.data.os, 'os').toEqual(agent.os.name + ' ' + agent.os.version);
    expect(agentPs.data.os_type, 'os_type').toEqual(os.sysname || agent.os.platform);
    expect(agentPs.data.field_agent_id, 'field_agent_id').toEqual(agent.id);
    expect(agentPs.data.name.toLowerCase(), 'name').toEqual(agentNameSplit[0]);
    expect(agentPs.data.hostname.toLowerCase(), 'hostname').toEqual(agent.name);
  } else if (action === PSAction.cpu) {
    const hardware = await syscollectorService.getHardware(id);

    expect(agentPs.data.cpu_name, 'cpu_name').toEqual(hardware.cpu.name);
    expect(agentPs.data.cpu_freq, 'cpu_freq').toEqual(hardware.cpu.mhz);
    expect(agentPs.data.memory_free !== 0, 'memory_free').toBeTruthy();
    expect(agentPs.data.memory_total !== 0, 'memory_total').toBeTruthy();
  } else if (action === PSAction.disk) {
    const hdd = await syscollectorService.getHdd(id);

    expect(
      agentPs.data.disk.map((element) => new AgentHddTestPythonScript(element)),
      'disk',
    ).toEqual(
      hdd
        .filter((element) => 'btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs'.includes(element.filesystem.toLowerCase()))
        .map((element) => new AgentHddTestPythonScript(element)),
    );
  } else if (action === PSAction.interfaces) {
    const netiface = (await syscollectorService.getNetiface(id)).filter((element) => !element.name.toLowerCase().includes('loopback'));
    const netaddr = (await syscollectorService.getNetaddr(id))
      .filter((element) => !element.iface.toLowerCase().includes('loopback'))
      .filter((element) => element.netmask);
    const result = {};

    netiface.forEach((iface) => {
      const { name, mac } = iface;
      const addresses = [];

      const matchingAddrs = netaddr.filter((addr) => addr.iface === name);

      matchingAddrs.forEach((addr) => {
        const { address, netmask, proto } = addr;
        addresses.push({ ip: address, mask: netmask, family: proto });
      });

      result[name] = { name, mac, address: addresses };
    });

    const interfaces = Object.values(result);

    expect(agentPs.data.interfaces, 'interfaces').toStrictEqual(interfaces);
  } else if (action === PSAction.sca) {
    const isNotEmptyArray = (arr: AgentSCA[] | AgentPackages[]): boolean => arr.length !== 0;
    const passed = 'passed';

    const sca = (await scaService.getSCA(id)).filter((element) => element.result === passed);
    const packages = await syscollectorService.getPackages(id);

    const autoupdate =
      isNotEmptyArray(sca.filter((element) => element.id === 1000 || element.id === 991000)) ||
      isNotEmptyArray(packages.filter((element) => element.name === 'unattended-upgrades' || element.name === 'yum-cron' || element.name === 'astra-update'));

    expect(agentPs.data.autoupdate, 'autoupdate').toBe(autoupdate ? 4 : 0);
    expect(agentPs.data.usb, 'usb').toBe(!isNotEmptyArray(sca.filter((element) => element.id === 1002)));
    expect(agentPs.data.firewall, 'firewall').toBe(
      isNotEmptyArray(sca.filter((element) => element.id === 1003 || element.id === 1004 || element.id === 1005 || element.id === 991003)),
    );
    expect(agentPs.data.autorun_drive, 'autorun_drive').toBe(isNotEmptyArray(sca.filter((element) => element.id === 1001)));
  } else if (action === PSAction.scan) {
    const scan = await vulnerabilityService.getLastScan(id);

    expect(agentPs.data.scanned_at, 'scanned_at').toEqual(scan.lastFullScan);
  } else if (action === PSAction.softwareIncluded) {
    const packages = await syscollectorService.getPackages(id);

    expect(
      agentPs.data.softwareIncluded ? agentPs.data.softwareIncluded.map((element) => new PackagesTestPythonScript(element)) : [],
      'softwareIncluded',
    ).toEqual(packages.map((element) => new PackagesTestPythonScript(element)));
  } else if (action === PSAction.updates) {
    const hotfixes = await syscollectorService.getHotfixes(id);

    expect(agentPs.data.updates ? agentPs.data.updates.map((element) => new HotfixesTestPythonScript(element)) : [], 'updates').toEqual(
      hotfixes.map((element) => new HotfixesTestPythonScript(element)),
    );
  } else if (action === PSAction.usersIncluded) {
    const accounts = await syscollectorService.getAccounts(id);

    expect(
      agentPs.data.usersIncluded.map((element) => new AgentAccounts(element)),
      'usersIncluded',
    ).toEqual(accounts);
  } else if (action === PSAction.vulnerabilities) {
    const vulnerability = await vulnerabilityService.getVulnerability(id);

    expect(
      agentPs.data.vulnerabilities ? agentPs.data.vulnerabilities.map((element) => new VulnerabilityTestPythonScript(element)) : [],
      'vulnerabilities',
    ).toEqual(vulnerability.map((element) => new VulnerabilityTestPythonScript(element)));
  }
}

можно оставить функцию такой или лучше раскидать на отдельные функции