aboutsummaryrefslogtreecommitdiff
path: root/tests/modules/systemd
diff options
context:
space:
mode:
authorRobert Helgesson <robert@rycee.net>2019-03-24 15:52:30 +0100
committerRobert Helgesson <robert@rycee.net>2019-03-24 15:52:30 +0100
commit6ebf14143aee10d8a62eb660bb56ebed3ed674e2 (patch)
tree6ab39013fa88cfe76dd9dc0c5b4263db5b6d3fb5 /tests/modules/systemd
parentcf5dac9563d9376abc5e81eb9f92ac533e80d531 (diff)
systemd: add some basic tests
Diffstat (limited to 'tests/modules/systemd')
-rw-r--r--tests/modules/systemd/default.nix4
-rw-r--r--tests/modules/systemd/services-expected.conf5
-rw-r--r--tests/modules/systemd/services.nix23
-rw-r--r--tests/modules/systemd/timers-expected.conf8
-rw-r--r--tests/modules/systemd/timers.nix31
5 files changed, 71 insertions, 0 deletions
diff --git a/tests/modules/systemd/default.nix b/tests/modules/systemd/default.nix
new file mode 100644
index 00000000000..cc1d5b6baa3
--- /dev/null
+++ b/tests/modules/systemd/default.nix
@@ -0,0 +1,4 @@
+{
+ systemd-services = ./services.nix;
+ systemd-timers = ./timers.nix;
+}
diff --git a/tests/modules/systemd/services-expected.conf b/tests/modules/systemd/services-expected.conf
new file mode 100644
index 00000000000..34b9618d6d3
--- /dev/null
+++ b/tests/modules/systemd/services-expected.conf
@@ -0,0 +1,5 @@
+[Service]
+ExecStart=/some/exec/start/command --with-arguments "%i"
+
+[Unit]
+Description=A basic test service
diff --git a/tests/modules/systemd/services.nix b/tests/modules/systemd/services.nix
new file mode 100644
index 00000000000..f1f7a42bb1a
--- /dev/null
+++ b/tests/modules/systemd/services.nix
@@ -0,0 +1,23 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+ config = {
+ systemd.user.services."test-service@" = {
+ Unit = {
+ Description = "A basic test service";
+ };
+
+ Service = {
+ ExecStart = ''/some/exec/start/command --with-arguments "%i"'';
+ };
+ };
+
+ nmt.script = ''
+ local serviceFile=home-files/.config/systemd/user/test-service@.service
+ assertFileExists $serviceFile
+ assertFileContent $serviceFile ${./services-expected.conf}
+ '';
+ };
+}
diff --git a/tests/modules/systemd/timers-expected.conf b/tests/modules/systemd/timers-expected.conf
new file mode 100644
index 00000000000..b19f044cc0b
--- /dev/null
+++ b/tests/modules/systemd/timers-expected.conf
@@ -0,0 +1,8 @@
+[Install]
+WantedBy=timers.target
+
+[Timer]
+OnUnitActiveSec=1h 30m
+
+[Unit]
+Description=A basic test timer
diff --git a/tests/modules/systemd/timers.nix b/tests/modules/systemd/timers.nix
new file mode 100644
index 00000000000..0fa0070cd77
--- /dev/null
+++ b/tests/modules/systemd/timers.nix
@@ -0,0 +1,31 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+ config = {
+ systemd.user.timers.test-timer = {
+ Unit = {
+ Description = "A basic test timer";
+ };
+
+ Timer = {
+ OnUnitActiveSec = "1h 30m";
+ };
+
+ Install = {
+ WantedBy = [ "timers.target" ];
+ };
+ };
+
+ nmt.script = ''
+ local unitDir=home-files/.config/systemd/user
+ local timerFile=$unitDir/test-timer.timer
+
+ assertFileExists $timerFile
+ assertFileContent $timerFile ${./timers-expected.conf}
+
+ assertFileExists $unitDir/timers.target.wants/test-timer.timer
+ '';
+ };
+}