inventory/tests: remove unused tests

This commit is contained in:
Johannes Kirschbauer
2025-08-16 12:46:57 +02:00
parent 72e7c2e9b9
commit 3c34f81a44
5 changed files with 8 additions and 217 deletions

View File

@@ -1,12 +1,8 @@
{ {
self, self,
inputs,
options, options,
... ...
}: }:
let
inputOverrides = self.clanLib.flake-inputs.getOverrides inputs;
in
{ {
imports = [ imports = [
./distributed-service/flake-module.nix ./distributed-service/flake-module.nix
@@ -15,16 +11,13 @@ in
{ {
pkgs, pkgs,
lib, lib,
config,
system,
self', self',
... ...
}: }:
{ {
devShells.inventory-schema = pkgs.mkShell { devShells.inventory-schema = pkgs.mkShell {
name = "clan-inventory-schema"; name = "clan-inventory-schema";
inputsFrom = with config.checks; [ inputsFrom = [
eval-lib-inventory
self'.devShells.default self'.devShells.default
]; ];
}; };
@@ -51,41 +44,5 @@ in
warningsAreErrors = true; warningsAreErrors = true;
transformOptions = self.clanLib.docs.stripStorePathsFromDeclarations; transformOptions = self.clanLib.docs.stripStorePathsFromDeclarations;
}).optionsJSON; }).optionsJSON;
# Run: nix-unit --extra-experimental-features flakes --flake .#legacyPackages.x86_64-linux.evalTests
legacyPackages.evalTests-inventory = import ./tests {
inherit lib;
clan-core = self;
inherit (self) clanLib;
inherit (self.inputs) nix-darwin;
};
checks = {
eval-lib-inventory = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
export HOME="$(realpath .)"
export NIX_ABORT_ON_WARN=1
nix-unit --eval-store "$HOME" \
--extra-experimental-features flakes \
--show-trace \
${inputOverrides} \
--flake ${
lib.fileset.toSource {
root = ../../..;
fileset = lib.fileset.unions [
../../../flake.nix
../../../flake.lock
(lib.fileset.fileFilter (file: file.name == "flake-module.nix") ../../..)
../../../flakeModules
../../../lib
../../../nixosModules/clanCore
../../../machines
../../../inventory.json
];
}
}#legacyPackages.${system}.evalTests-inventory
touch $out
'';
};
}; };
} }

View File

@@ -1,90 +0,0 @@
{
clan-core,
nix-darwin,
lib,
clanLib,
}:
let
# TODO: Unify these tests with clan tests
clan =
m:
lib.evalModules {
specialArgs = { inherit clan-core nix-darwin clanLib; };
modules = [
clan-core.modules.clan.default
{
self = { };
}
m
];
};
in
{
test_inventory_a =
let
eval = clan {
inventory = {
machines = {
A = { };
};
services = {
legacyModule = { };
};
modules = {
legacyModule = ./legacyModule;
};
};
directory = ./.;
};
in
{
inherit eval;
expr = {
legacyModule = lib.filterAttrs (
name: _: name == "isClanModule"
) eval.config.clanInternals.inventoryClass.machines.A.compiledServices.legacyModule;
};
expected = {
legacyModule = {
};
};
};
test_inventory_empty =
let
eval = clan {
inventory = { };
directory = ./.;
};
in
{
# Empty inventory should return an empty module
expr = eval.config.clanInternals.inventoryClass.machines;
expected = { };
};
test_inventory_module_doesnt_exist =
let
eval = clan {
directory = ./.;
inventory = {
services = {
fanatasy.instance_1 = {
roles.default.machines = [ "machine_1" ];
};
};
machines = {
"machine_1" = { };
};
};
};
in
{
inherit eval;
expr = eval.config.clanInternals.inventoryClass.machines.machine_1.machineImports;
expectedError = {
type = "ThrownError";
msg = "ClanModule not found*";
};
};
}

View File

@@ -1,4 +0,0 @@
---
features = [ "inventory" ]
---
Description

View File

@@ -1,9 +0,0 @@
{
lib,
clan-core,
...
}:
{
# Just some random stuff
options.test = lib.mapAttrs clan-core;
}

View File

@@ -16,76 +16,13 @@ in
type = types.raw; type = types.raw;
}; };
machines = mkOption { machines = mkOption {
type = types.attrsOf ( type = types.attrsOf (submodule ({
submodule ( options = {
{ name, ... }: machineImports = mkOption {
let type = types.listOf types.raw;
machineName = name; };
in };
{ }));
options = {
compiledMachine = mkOption {
type = types.raw;
};
compiledServices = mkOption {
# type = types.attrsOf;
type = types.attrsOf (
types.submoduleWith {
modules = [
(
{ name, ... }:
let
serviceName = name;
in
{
options = {
machineName = mkOption {
default = machineName;
readOnly = true;
};
serviceName = mkOption {
default = serviceName;
readOnly = true;
};
# Outputs
machineImports = mkOption {
type = types.listOf types.raw;
};
supportedRoles = mkOption {
type = types.listOf types.str;
};
matchedRoles = mkOption {
type = types.listOf types.str;
};
machinesRoles = mkOption {
type = types.attrsOf (types.listOf types.str);
};
resolvedRolesPerInstance = mkOption {
type = types.attrsOf (
types.attrsOf (submodule {
options.machines = mkOption {
type = types.listOf types.str;
};
})
);
};
assertions = mkOption {
type = types.attrsOf types.raw;
};
};
}
)
];
}
);
};
machineImports = mkOption {
type = types.listOf types.raw;
};
};
}
)
);
}; };
}; };
} }