generate-test-vars: fake prompt inputs

Use fake prompt inputs when generating vars for testing
This commit is contained in:
DavHau
2025-05-31 17:14:26 +07:00
parent d27834b565
commit 65d9ef02dc
3 changed files with 77 additions and 11 deletions

View File

@@ -7,6 +7,10 @@ let
mkOption
removePrefix
types
mapAttrsToList
flip
unique
flatten
;
in
@@ -46,10 +50,18 @@ in
testSrc = lib.cleanSource test.config.clan.directory;
inputsForMachine =
machine:
flip mapAttrsToList machine.clan.core.vars.generators (_name: generator: generator.runtimeInputs);
generatorRuntimeInputs = unique (
flatten (flip mapAttrsToList test.config.nodes (_machineName: machine: inputsForMachine machine))
);
vars-check =
pkgs.runCommand "update-vars-check"
{
nativeBuildInputs = [
nativeBuildInputs = generatorRuntimeInputs ++ [
pkgs.nix
pkgs.git
pkgs.age
@@ -57,7 +69,7 @@ in
pkgs.bubblewrap
];
closureInfo = pkgs.closureInfo {
rootPaths = [
rootPaths = generatorRuntimeInputs ++ [
pkgs.bash
pkgs.coreutils
pkgs.jq.dev
@@ -74,7 +86,9 @@ in
cp -r ${testSrc} ./src
chmod +w -R ./src
find ./src/sops ./src/vars | sort > filesBefore
${update-vars-script} ./src ${testName} --repo-root ${self.packages.${pkgs.system}.clan-core-flake}
${update-vars-script} ./src ${testName} \
--repo-root ${self.packages.${pkgs.system}.clan-core-flake} \
--clean
find ./src/sops ./src/vars | sort > filesAfter
if ! diff -q filesBefore filesAfter; then
echo "The update-vars script changed the files in ${testSrc}."