From 0590c2a4f64871d00487639220d04955194bc172 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 31 Jan 2019 02:08:40 +0100 Subject: [PATCH] mbsync: add basic test of result configuration --- modules/programs/mbsync.nix | 2 +- tests/default.nix | 1 + tests/modules/programs/mbsync-expected.conf | 55 +++++++++++++++++++++ tests/modules/programs/mbsync.nix | 35 +++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 tests/modules/programs/mbsync-expected.conf create mode 100644 tests/modules/programs/mbsync.nix diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index bb81992d..209db0dc 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -176,7 +176,7 @@ in ++ accountsConfig ++ groupsConfig ++ optional (cfg.extraConfig != "") cfg.extraConfig - ); + ) + "\n"; home.activation.createMaildir = dag.entryBetween [ "linkGeneration" ] [ "writeBoundary" ] '' diff --git a/tests/default.nix b/tests/default.nix index 279fc631..5002ae2c 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -23,6 +23,7 @@ import nmt { git-with-email = ./modules/programs/git-with-email.nix; git-with-most-options = ./modules/programs/git.nix; git-with-str-extra-config = ./modules/programs/git-with-str-extra-config.nix; + mbsync = ./modules/programs/mbsync.nix; texlive-minimal = ./modules/programs/texlive-minimal.nix; xresources = ./modules/xresources.nix; } // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { diff --git a/tests/modules/programs/mbsync-expected.conf b/tests/modules/programs/mbsync-expected.conf new file mode 100644 index 00000000..f1ca79fe --- /dev/null +++ b/tests/modules/programs/mbsync-expected.conf @@ -0,0 +1,55 @@ +# Generated by Home Manager. + +IMAPAccount hm-account +CertificateFile /etc/ssl/certs/ca-certificates.crt +Host imap.example.org +PassCmd "password-command 2" +SSLType IMAPS +User home.manager.jr + +IMAPStore hm-account-remote +Account hm-account + +MaildirStore hm-account-local +Inbox /home/hm-user/Mail/hm-account/Inbox +Path /home/hm-user/Mail/hm-account/ +SubFolders Verbatim + +Channel hm-account +Create None +Expunge None +Master :hm-account-remote: +Patterns * +Remove None +Slave :hm-account-local: +SyncState * + + +IMAPAccount hm@example.com +CertificateFile /etc/ssl/certs/ca-certificates.crt +Host imap.example.com +PassCmd password-command +SSLType IMAPS +User home.manager + +IMAPStore hm@example.com-remote +Account hm@example.com + +MaildirStore hm@example.com-local +Inbox /home/hm-user/Mail/hm@example.com/Inbox +Path /home/hm-user/Mail/hm@example.com/ +SubFolders Verbatim + +Channel hm@example.com +Create None +Expunge None +Master :hm@example.com-remote: +Patterns * +Remove None +Slave :hm@example.com-local: +SyncState * + + +Group inboxes +Channel hm-account:Inbox +Channel hm@example.com:Inbox1,Inbox2 diff --git a/tests/modules/programs/mbsync.nix b/tests/modules/programs/mbsync.nix new file mode 100644 index 00000000..fa9768a2 --- /dev/null +++ b/tests/modules/programs/mbsync.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + imports = [ ../accounts/email-test-accounts.nix ]; + + config = { + home.username = "hm-user"; + home.homeDirectory = "/home/hm-user"; + + programs.mbsync = { + enable = true; + groups.inboxes = { + "hm@example.com" = [ "Inbox1" "Inbox2" ]; + hm-account = [ "Inbox" ]; + }; + }; + + accounts.email.accounts = { + "hm@example.com".mbsync = { + enable = true; + }; + + hm-account.mbsync = { + enable = true; + }; + }; + + nmt.script = '' + assertFileExists home-files/.mbsyncrc + assertFileContent home-files/.mbsyncrc ${./mbsync-expected.conf} + ''; + }; +}