Skip to content

Commit

Permalink
extend basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
nzbr committed Nov 10, 2022
1 parent d75cc32 commit 1a5804b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
35 changes: 33 additions & 2 deletions tests/basic-functionality.spec.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,43 @@
$id = WSL-Install

try {

# Run command through installer
WSL-Launch $id "nixos-version"
if ($LASTEXITCODE -ne 0) {
throw "Failed to run nixos-version inside the container"
throw "Failed to run a command through the installer"
}
# Run another command after the installer is done
WSL-Launch $id "true"
if ($LASTEXITCODE -ne 0) {
throw "Failed to run a second command"
}

# Restart the container and run a command
WSL-Shutdown $id
WSL-Launch $id "true"
if ($LASTEXITCODE -ne 0) {
throw "Failed to run command after restart"
}

# nixos-rebuild works
WSL-Launch $id "sudo nixos-rebuild switch"
if ($LASTEXITCODE -ne 0) {
throw "Failed to run nixos-rebuild"
}

# nix-shell works
WSL-Launch $id "nix-shell -p neofetch --command neofetch"
if ($LASTEXITCODE -ne 0) {
throw "Failed to run a command through nix-shell"
}

# nix run works
WSL-Launch $id "nix run nixpkgs#neofetch"
if ($LASTEXITCODE -ne 0) {
throw "Failed to run a command through nix run"
}

# TODO: WSL-Shutdown
}
finally {
WSL-Uninstall($id)
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/lib_linux.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function WSL-Launch([string]$id, [string]$command) {
# TODO: WSL-CopyFile

function WSL-Shutdown([string]$id) {
docker stop $id
docker restart $id # Restart instead of stop so that exec can still be used
if ($LASTEXITCODE -ne 0) {
throw "Failed to stop container"
}
Expand Down

0 comments on commit 1a5804b

Please sign in to comment.