tests: move git and files tests to directories

This commit is contained in:
Robert Helgesson 2019-12-08 21:39:45 +01:00
parent 5c9ec0d8e9
commit bcfc52cb85
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
9 changed files with 14 additions and 8 deletions

View file

@ -0,0 +1,5 @@
{
git-with-email = ./git-with-email.nix;
git-with-most-options = ./git.nix;
git-with-str-extra-config = ./git-with-str-extra-config.nix;
}

View file

@ -0,0 +1,42 @@
[alias]
a1=foo
a2=baz
[commit]
gpgSign=true
[extra]
boolean=true
integer=38
multiple=1
multiple=2
name=value
[extra "backcompat.with.dots"]
previously=worked
[extra "subsection"]
value=test
[filter "lfs"]
clean=git-lfs clean -- %f
process=git-lfs filter-process
required=true
smudge=git-lfs smudge -- %f
[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
[includeIf "gitdir:~/src/dir"]
path=@git_include_path@

View file

@ -0,0 +1,15 @@
[sendemail "hm-account"]
from=hm@example.org
smtpEncryption=tls
smtpServer=smtp.example.org
smtpUser=home.manager.jr
[sendemail "hm@example.com"]
from=hm@example.com
smtpEncryption=tls
smtpServer=smtp.example.com
smtpUser=home.manager
[user]
email=hm@example.com
name=H. M. Test

View file

@ -0,0 +1,34 @@
{ config, lib, pkgs, ... }:
with lib;
{
imports = [ ../../accounts/email-test-accounts.nix ];
config = {
programs.git = {
enable = true;
package = pkgs.gitMinimal;
userEmail = "hm@example.com";
userName = "H. M. Test";
};
nmt.script = ''
function assertGitConfig() {
local value
value=$(${pkgs.git}/bin/git config \
--file $TESTED/home-files/.config/git/config \
--get $1)
if [[ $value != $2 ]]; then
fail "Expected option '$1' to have value '$2' but it was '$value'"
fi
}
assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config ${./git-with-email-expected.conf}
assertGitConfig "sendemail.hm@example.com.from" "hm@example.com"
assertGitConfig "sendemail.hm-account.from" "hm@example.org"
'';
};
}

View file

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

View file

@ -0,0 +1,23 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.git = {
enable = true;
package = pkgs.gitMinimal;
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,75 @@
{ config, lib, pkgs, ... }:
with lib;
let
gitInclude = {
user = {
name = "John Doe";
email = "user@example.org";
};
};
substituteExpected = path: pkgs.substituteAll {
src = path;
git_include_path = pkgs.writeText "contents" (generators.toINI {} gitInclude);
};
in
{
config = {
programs.git = mkMerge [
{
enable = true;
package = pkgs.gitMinimal;
aliases = {
a1 = "foo";
a2 = "bar";
};
extraConfig = {
extra = {
name = "value";
multiple = [1];
};
};
ignores = [ "*~" "*.swp" ];
includes = [
{ path = "~/path/to/config.inc"; }
{
path = "~/path/to/conditional.inc";
condition = "gitdir:~/src/dir";
}
{
condition = "gitdir:~/src/dir";
contents = gitInclude;
}
];
signing = {
gpgPath = "path-to-gpg";
key = "00112233445566778899AABBCCDDEEFF";
signByDefault = true;
};
userEmail = "user@example.org";
userName = "John Doe";
lfs.enable = true;
}
{
aliases.a2 = mkForce "baz";
extraConfig."extra \"backcompat.with.dots\"".previously = "worked";
extraConfig.extra.boolean = true;
extraConfig.extra.integer = 38;
extraConfig.extra.multiple = [2];
extraConfig.extra.subsection.value = "test";
}
];
nmt.script = ''
assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config ${substituteExpected ./git-expected.conf}
'';
};
}