tests: Add environment

This commit is contained in:
Tim Steinbach 2017-09-05 19:05:37 -04:00
parent 3e2975e892
commit b4ccef2163
No known key found for this signature in database
GPG Key ID: 472BFCCA96BD0EDA
3 changed files with 37 additions and 0 deletions

View File

@ -82,6 +82,7 @@ in rec {
(all nixos.tests.boot-stage1)
nixos.tests.hibernate.x86_64-linux # i686 is flaky, see #23107
(all nixos.tests.ecryptfs)
(all nixos.tests.env)
(all nixos.tests.ipv6)
(all nixos.tests.i3wm)
(all nixos.tests.keymap.azerty)

View File

@ -240,6 +240,7 @@ in rec {
tests.ec2-nixops = hydraJob (import tests/ec2.nix { system = "x86_64-linux"; }).boot-ec2-nixops;
tests.ec2-config = hydraJob (import tests/ec2.nix { system = "x86_64-linux"; }).boot-ec2-config;
tests.elk = callTest tests/elk.nix {};
tests.env = callTest tests/env.nix {};
tests.ferm = callTest tests/ferm.nix {};
tests.firefox = callTest tests/firefox.nix {};
tests.firewall = callTest tests/firewall.nix {};

35
nixos/tests/env.nix Normal file
View File

@ -0,0 +1,35 @@
import ./make-test.nix ({ pkgs, ...} : {
name = "environment";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ nequissimus ];
};
machine = { config, lib, pkgs, ... }:
{
boot.kernelPackages = pkgs.linuxPackages;
environment.etc."plainFile".text = ''
Hello World
'';
environment.etc."folder/with/file".text = ''
Foo Bar!
'';
environment.sessionVariables = {
TERMINFO_DIRS = "/run/current-system/sw/share/terminfo";
NIXCON = "awesome";
};
};
testScript =
''
$machine->succeed('[ -L "/etc/plainFile" ]');
$machine->succeed('cat "/etc/plainFile" | grep "Hello World"');
$machine->succeed('[ -d "/etc/folder" ]');
$machine->succeed('[ -d "/etc/folder/with" ]');
$machine->succeed('[ -L "/etc/folder/with/file" ]');
$machine->succeed('cat "/etc/plainFile" | grep "Hello World"');
$machine->succeed('echo ''${TERMINFO_DIRS} | grep "/run/current-system/sw/share/terminfo"');
$machine->succeed('echo ''${NIXCON} | grep "awesome"');
'';
})