diff options
| author | K900 <me@0upti.me> | 2023-09-29 22:36:09 +0300 |
|---|---|---|
| committer | K900 <me@0upti.me> | 2023-09-29 22:37:58 +0300 |
| commit | 5bca9165acee81d3187fb75df858db765de102cd (patch) | |
| tree | bf108964fffbfe7f17e1945a68b39bf5f5f522b0 /tests | |
| parent | 9bff9a09a4eb89ca814d4e069c00e52f6c901cdf (diff) | |
cleanup: clean up tests, don't rely on base config
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/README.md | 2 | ||||
| -rw-r--r-- | tests/docker/docker-native.nix | 14 | ||||
| -rw-r--r-- | tests/lib/lib.ps1 | 4 | ||||
| -rw-r--r-- | tests/login-shell/session-variables.nix | 6 | ||||
| -rw-r--r-- | tests/shells.Tests.ps1 | 9 | ||||
| -rw-r--r-- | tests/username-change/username-change.nix | 8 |
6 files changed, 27 insertions, 16 deletions
diff --git a/tests/README.md b/tests/README.md index d3c66d2..7c5eb92 100644 --- a/tests/README.md +++ b/tests/README.md @@ -46,6 +46,6 @@ BeforeAll { - A Distro object has the following methods: - `Launch($command)`: Runs the specified command inside the container. Returns the command output - `GetPath($path)`: Returns the path inside the container, that points to the specified file on the host. - - `InstallConfig($path)`: Installs a nix-file as the systems `configuration.nix`. The default configuration is moved to `base.nix`, so that it can be imported by the new config + - `InstallConfig($path)`: Installs a nix-file as the systems `configuration.nix`. - `Shutdown()`: End all processes running in the container - `Uninstall()`: Stop and then delete the container from the system. This should be called in an AfterEach or AfterAll block, so that the test does not leave it on the system. diff --git a/tests/docker/docker-native.nix b/tests/docker/docker-native.nix index f9319fe..f119482 100644 --- a/tests/docker/docker-native.nix +++ b/tests/docker/docker-native.nix @@ -1,8 +1,14 @@ { - imports = [ ./base.nix ]; + imports = [ + <nixos-wsl/modules> + ]; - # Github Actions runners try to use aufs and fail if this is not set explicitly - virtualisation.docker.daemon.settings = { - "storage-driver" = "vfs"; + wsl.enable = true; + users.users.nixos.extraGroups = [ "docker" ]; + + virtualisation.docker = { + enable = true; + # Github Actions runners try to use aufs and fail if this is not set explicitly + daemon.settings."storage-driver" = "vfs"; }; } diff --git a/tests/lib/lib.ps1 b/tests/lib/lib.ps1 index 006eefe..e3985c9 100644 --- a/tests/lib/lib.ps1 +++ b/tests/lib/lib.ps1 @@ -37,10 +37,6 @@ class Distro { [void]InstallConfig([string]$path) { Write-Host "Installing config: $path" - # Move config out of the way - $this.Launch("/bin/sh -c 'test -f /etc/nixos/base.nix || sudo mv /etc/nixos/configuration.nix /etc/nixos/base.nix'") - $LASTEXITCODE | Should -Be 0 - # Copy the new config $this.Launch("sudo cp $($this.GetPath($path)) /etc/nixos/configuration.nix") $LASTEXITCODE | Should -Be 0 diff --git a/tests/login-shell/session-variables.nix b/tests/login-shell/session-variables.nix index d6525ed..6829bbf 100644 --- a/tests/login-shell/session-variables.nix +++ b/tests/login-shell/session-variables.nix @@ -1,13 +1,15 @@ -{ config, pkgs, lib, ... }: +{ pkgs, lib, ... }: let ver = with lib; substring 0 5 version; in { imports = [ - ./base.nix + <nixos-wsl/modules> "${builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-${ver}.tar.gz"}/nixos" ]; + wsl.enable = true; + home-manager.users.nixos = { ... }: { home = { stateVersion = ver; diff --git a/tests/shells.Tests.ps1 b/tests/shells.Tests.ps1 index 184014b..6bcc640 100644 --- a/tests/shells.Tests.ps1 +++ b/tests/shells.Tests.ps1 @@ -11,10 +11,15 @@ Describe "Shells" { @" { pkgs, lib, config, options, ... }: with lib; { - imports = [ ./base.nix ]; + imports = [ + <nixos-wsl/modules> + ]; config = mkMerge [ - { users.users.`${config.wsl.defaultUser}.shell = pkgs.$package; } + { + wsl.enable = true; + users.users.nixos.shell = pkgs.$package; + } (optionalAttrs (hasAttrByPath ["programs" "$package" "enable"] options) { programs.$package.enable = true; }) diff --git a/tests/username-change/username-change.nix b/tests/username-change/username-change.nix index 77a2cdd..32d7e1e 100644 --- a/tests/username-change/username-change.nix +++ b/tests/username-change/username-change.nix @@ -1,6 +1,8 @@ -{ pkgs, lib, ... }: { - imports = [ ./base.nix ]; + imports = [ + <nixos-wsl/modules> + ]; - wsl.defaultUser = lib.mkForce "different-name"; + wsl.enable = true; + wsl.defaultUser = "different-name"; } |
