tests: move git and files tests to directories
This commit is contained in:
parent
5c9ec0d8e9
commit
bcfc52cb85
9 changed files with 14 additions and 8 deletions
5
tests/modules/programs/git/default.nix
Normal file
5
tests/modules/programs/git/default.nix
Normal 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;
|
||||
}
|
||||
42
tests/modules/programs/git/git-expected.conf
Normal file
42
tests/modules/programs/git/git-expected.conf
Normal 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@
|
||||
15
tests/modules/programs/git/git-with-email-expected.conf
Normal file
15
tests/modules/programs/git/git-with-email-expected.conf
Normal 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
|
||||
34
tests/modules/programs/git/git-with-email.nix
Normal file
34
tests/modules/programs/git/git-with-email.nix
Normal 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"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
This can be anything.
|
||||
|
||||
[user]
|
||||
email=user@example.org
|
||||
name=John Doe
|
||||
23
tests/modules/programs/git/git-with-str-extra-config.nix
Normal file
23
tests/modules/programs/git/git-with-str-extra-config.nix
Normal 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}
|
||||
'';
|
||||
};
|
||||
}
|
||||
75
tests/modules/programs/git/git.nix
Normal file
75
tests/modules/programs/git/git.nix
Normal 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}
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue