aboutsummaryrefslogtreecommitdiff
path: root/home-manager/tests/modules/programs/git/git-with-email.nix
blob: d7ed7e185de97ea296299920fdfe715e992834c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{ 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";
    };

    home.stateVersion = "20.09";

    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"
    '';
  };
}