summaryrefslogtreecommitdiffstats
path: root/tests/infrastructure/default.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-10-30 15:15:04 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-10-30 15:15:04 +0100
commit43dac390967e2e85da0b3fcd84043a77cfaddfd0 (patch)
tree93f09b804bcded8b59db6f619e18ec4b6265b8c2 /tests/infrastructure/default.nix
parenttreewide: Align files with the same files in the `nixos-server` repo (diff)
downloadnixos-config-43dac390967e2e85da0b3fcd84043a77cfaddfd0.zip
treewide: Align the rest of the files with the server repository
Diffstat (limited to 'tests/infrastructure/default.nix')
-rw-r--r--tests/infrastructure/default.nix177
1 files changed, 0 insertions, 177 deletions
diff --git a/tests/infrastructure/default.nix b/tests/infrastructure/default.nix
deleted file mode 100644
index cd21198c..00000000
--- a/tests/infrastructure/default.nix
+++ /dev/null
@@ -1,177 +0,0 @@
-# nixos-config - My current NixOS configuration
-#
-# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-# This file is part of my nixos-config.
-#
-# You should have received a copy of the License along with this program.
-# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
-{
- pkgs,
- myPkgs,
- lib,
- nixos-lib,
- extraModules,
- sysLib,
- nixpkgs_open_prs,
- system,
-}: {
- name,
- configuration,
- description,
- hash,
- testData,
- testShell ? pkgs.dash,
- alternateScreen ? false,
-}:
-nixos-lib.runTest {
- hostPkgs = pkgs; # the Nixpkgs package set used outside the VMs
-
- inherit name;
-
- node = {
- specialArgs = {
- inherit
- myPkgs
- sysLib
- nixpkgs_open_prs
- system
- ;
- };
- # Use the nixpkgs as constructed by the `nixpkgs.*` options
- pkgs = null;
- };
-
- nodes = {
- machine = {config, ...}: {
- imports =
- [
- extraModules.home-manager
- ../../modules/by-name/us/users/module.nix
- ]
- ++ configuration.imports;
-
- config = lib.modules.mkMerge [
- {
- soispha = {
- users = {
- enable = true;
-
- # The password is 'test'.
- hashedPassword = "$y$j9T$yYYUpE9OaxmEO8MaPI2jr0$WGpYYWaLySakI.Mwqz4sljGSOetAp4s5CIUa1VUU1l2";
- };
- };
- home-manager.users.soispha.home.stateVersion = "24.11";
- }
- configuration.config
- ];
- };
- };
-
- testScript = {nodes, ...}: let
- testDir = "${nodes.machine.home-manager.users.soispha.home.homeDirectory}/test";
- goldenFile = "${testDir}/__test_golden";
- logFile = "${testDir}/__test_log";
- testTmux = lib.getExe pkgs.tmux;
- in
- /*
- python
- */
- ''
- start_all()
-
- __TEST_TMUX="${testTmux}"
-
- machine.succeed("sudo -u soispha ${pkgs.writeShellScript "mkTestEnvironment" ''
- set -e
-
- mkdir --parents "${testDir}"
- cd "${testDir}"
-
- ${
- lib.strings.concatStringsSep "\n\n" (
- builtins.attrValues
- (builtins.mapAttrs
- (name: value: ''
- mkdir --parents "$(dirname '${name}')"
- cp --recursive '${value}' '${name}'
- '')
- testData)
- )
- }
- ''}")
-
- machine.succeed("sudo -u soispha ${pkgs.writeShellScript "mkGoldenRecord" ''
- set -e
-
- # HACK: Prevent zsh from complaining about missing configuration.
- # TODO: These tests should probably just run under bash. <2024-11-22>
- touch ~soispha/.zshrc
-
- cd "${testDir}"
-
- __TEST_TMUX="${testTmux}"
- __TEST_SHELL="${lib.getExe testShell}"
- __TEST_TMUX_PANE="__TEST_TMUX_PANE"
-
- __TEST_EVAL_USE_ALTERNATE_SCREEN="${
- if alternateScreen
- then "true"
- else "false"
- }"
- __TEST_EVAL_AWK_CLEAN_FILE="${./clean.awk}"
- __TEST_EVAL_LOG_FILE="${logFile}"
- __TEST_EVAL_GOLDEN_FILE="$(mktemp)"
- printf "%s" "${goldenFile}" >"$__TEST_EVAL_GOLDEN_FILE"
-
- . ${./driver.sh}
-
- "$__TEST_TMUX" new-session -d -s "$__TEST_TMUX_PANE" "$__TEST_SHELL"
-
- # Warm up the shell in the tmux sesssion
- "$__TEST_TMUX" send-keys -t "$__TEST_TMUX_PANE" "echo hi" "Enter" "clear" "Enter"
- sleep 2
-
- "$__TEST_TMUX" pipe-pane -t "$__TEST_TMUX_PANE" -o 'cat >>${goldenFile}'
-
- __test_eval "${description}"
-
- # Remove the pipe
- "$__TEST_TMUX" pipe-pane -t "$__TEST_TMUX_PANE"
-
- # Check if the golden file was changed.
- if [ "$(cat "$__TEST_EVAL_GOLDEN_FILE")" != "${goldenFile}" ]; then
- mv "$(cat "$__TEST_EVAL_GOLDEN_FILE")" "${goldenFile}"
- fi
-
- rm "$__TEST_EVAL_GOLDEN_FILE"
- ''}")
-
- machine.succeed("sudo -u soispha ${pkgs.writeShellScript "testHashOfGolden" (''
- set -e
-
- cd "${testDir}"
- ''
- + lib.optionalString (hash != null)
- /*
- bash
- */
- ''
- golden_hash="$(sha256sum ${goldenFile} | awk '{print $1}')"
-
- if [ "$golden_hash" != "${hash}" ]; then
- echo "Hash mismatch."
- echo "Expected '${hash}',"
- echo "but got '$golden_hash'"
- exit 1
- else
- echo "Hash was successfully checked."
- fi
- '')}")
-
-
- machine.copy_from_vm("${goldenFile}", "golden")
- machine.copy_from_vm("${logFile}", "log")
- '';
-}