1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-19 14:53:00 +00:00
home-manager/tests/modules/programs/git/git-with-msmtp.nix
Vonfry 6f71acf71b
git: apply sendmailCmd instead of smtpServer (#6399)
In manpage of git-send-email --smtp-server,

    For backward compatibility, this option can also specify
    full pathname of a sendmail-like program instead; the program
    must support the -i option. This method does not support
    passing arguments or using plain command names. For those use
    cases, consider using --sendmail-cmd instead.
2025-03-04 22:46:31 +01:00

37 lines
1.1 KiB
Nix

{ pkgs, realPkgs, ... }:
{
imports = [ ../../accounts/email-test-accounts.nix ];
accounts.email.accounts."hm@example.com".msmtp.enable = true;
programs.git = {
enable = true;
signing.signer = "path-to-gpg";
userEmail = "hm@example.com";
userName = "H. M. Test";
};
home.stateVersion = "20.09";
nmt.script = ''
function assertGitConfig() {
local value
value=$(${realPkgs.gitMinimal}/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-msmtp-expected.conf}
assertGitConfig "sendemail.hm@example.com.from" "H. M. Test <hm@example.com>"
assertGitConfig "sendemail.hm-account.from" "H. M. Test Jr. <hm@example.org>"
assertGitConfig "sendemail.hm@example.com.sendmailCmd" "${pkgs.msmtp}/bin/msmtp"
assertGitConfig "sendemail.hm@example.com.envelopeSender" "auto"
'';
}