tests: add initial test framework

This commit is contained in:
Robert Helgesson 2018-12-11 00:51:48 +01:00
parent 5d63abb473
commit 6d56abcec1
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
9 changed files with 146 additions and 1 deletions

View File

@ -8,4 +8,5 @@ before_script:
- mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/$USER
script:
nix-shell . -A install
- nix-shell . -A install
- nix-shell . -A tests.run.all

View File

@ -11,4 +11,8 @@ rec {
};
nixos = import ./nixos;
tests = import ./tests {
inherit pkgs;
};
}

23
tests/default.nix Normal file
View File

@ -0,0 +1,23 @@
{ pkgs ? import <nixpkgs> {} }:
let
nmt = pkgs.fetchFromGitLab {
owner = "rycee";
repo = "nmt";
rev = "4d7b4bb34ed9df333b5aa54509e50881f3a59939";
sha256 = "1rha4n5xafxwa5gbrjwnm63z944jr27gv71krkzzmb5wapi1r36m";
};
in
import nmt {
inherit pkgs;
modules = import ../modules/modules.nix { inherit pkgs; lib = pkgs.lib; };
testedAttrPath = [ "home" "activationPackage" ];
tests = {
"git/with-most-options" = ./modules/programs/git.nix;
"git/with-str-extra-config" = ./modules/programs/git-with-str-extra-config.nix;
xresources = ./modules/xresources.nix;
};
}

View File

@ -0,0 +1,23 @@
[alias]
a1=foo
a2=bar
[commit]
gpgSign=true
[extra]
name=value
[gpg]
program=path-to-gpg
[user]
email=user@example.org
name=John Doe
signingKey=00112233445566778899AABBCCDDEEFF
[include]
path = ~/path/to/config.inc
[includeIf "gitdir:~/src/dir"]
path = ~/path/to/conditional.inc

View File

@ -0,0 +1,5 @@
This can be anything.
[user]
email=user@example.org
name=John Doe

View File

@ -0,0 +1,22 @@
{ config, lib, ... }:
with lib;
{
config = {
programs.git = {
enable = true;
extraConfig = ''
This can be anything.
'';
userEmail = "user@example.org";
userName = "John Doe";
};
nmt.script = ''
assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config \
${./git-with-str-extra-config-expected.conf}
'';
};
}

View File

@ -0,0 +1,40 @@
{ config, lib, ... }:
with lib;
{
config = {
programs.git = {
enable = true;
aliases = {
a1 = "foo";
a2 = "bar";
};
extraConfig = {
extra = {
name = "value";
};
};
ignores = [ "*~" "*.swp" ];
includes = [
{ path = "~/path/to/config.inc"; }
{
path = "~/path/to/conditional.inc";
condition = "gitdir:~/src/dir";
}
];
signing = {
gpgPath = "path-to-gpg";
key = "00112233445566778899AABBCCDDEEFF";
signByDefault = true;
};
userEmail = "user@example.org";
userName = "John Doe";
};
nmt.script = ''
assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config ${./git-expected.conf}
'';
};
}

View File

@ -0,0 +1,5 @@
Test*boolean1: true
Test*boolean2: false
Test*int: 10
Test*list: list-str, true, false, 10
Test*string: test-string

View File

@ -0,0 +1,22 @@
{ config, lib, ... }:
with lib;
{
config = {
xresources = {
properties = {
"Test*string" = "test-string";
"Test*boolean1" = true;
"Test*boolean2" = false;
"Test*int" = 10;
"Test*list" = [ "list-str" true false 10 ];
};
};
nmt.script = ''
assertFileExists home-files/.Xresources
assertFileContent home-files/.Xresources ${./xresources-expected.conf}
'';
};
}