From 2c8489e57a04c913ba9e029cc2849a4bbac9673b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 25 May 2022 18:31:08 +0200 Subject: [PATCH] mpdris2: add basic test cases --- tests/default.nix | 1 + .../mpdris2/basic-configuration.config | 8 +++++++ .../services/mpdris2/basic-configuration.nix | 19 ++++++++++++++++ .../mpdris2/basic-configuration.service | 13 +++++++++++ tests/modules/services/mpdris2/default.nix | 4 ++++ .../services/mpdris2/with-password.config | 9 ++++++++ .../services/mpdris2/with-password.nix | 22 +++++++++++++++++++ 7 files changed, 76 insertions(+) create mode 100644 tests/modules/services/mpdris2/basic-configuration.config create mode 100644 tests/modules/services/mpdris2/basic-configuration.nix create mode 100644 tests/modules/services/mpdris2/basic-configuration.service create mode 100644 tests/modules/services/mpdris2/default.nix create mode 100644 tests/modules/services/mpdris2/with-password.config create mode 100644 tests/modules/services/mpdris2/with-password.nix diff --git a/tests/default.nix b/tests/default.nix index c420ae68c..141b2edd4 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -155,6 +155,7 @@ import nmt { ./modules/services/lieer ./modules/services/mopidy ./modules/services/mpd + ./modules/services/mpdris2 ./modules/services/pantalaimon ./modules/services/pbgopy ./modules/services/picom diff --git a/tests/modules/services/mpdris2/basic-configuration.config b/tests/modules/services/mpdris2/basic-configuration.config new file mode 100644 index 000000000..e68277562 --- /dev/null +++ b/tests/modules/services/mpdris2/basic-configuration.config @@ -0,0 +1,8 @@ +[Bling] +mmkeys = True +notify = True + +[Connection] +host = 127.0.0.1 +music_dir = /home/hm-user/music +port = 6600 diff --git a/tests/modules/services/mpdris2/basic-configuration.nix b/tests/modules/services/mpdris2/basic-configuration.nix new file mode 100644 index 000000000..5e809df39 --- /dev/null +++ b/tests/modules/services/mpdris2/basic-configuration.nix @@ -0,0 +1,19 @@ +{ ... }: + +{ + services.mpdris2 = { + enable = true; + notifications = true; + multimediaKeys = true; + }; + + test.stubs.mpdris2 = { }; + + nmt.script = '' + serviceFile=home-files/.config/systemd/user/mpdris2.service + assertFileContent "$serviceFile" ${./basic-configuration.service} + + configFile=home-files/.config/mpDris2/mpDris2.conf + assertFileContent "$configFile" ${./basic-configuration.config} + ''; +} diff --git a/tests/modules/services/mpdris2/basic-configuration.service b/tests/modules/services/mpdris2/basic-configuration.service new file mode 100644 index 000000000..2ea4656c7 --- /dev/null +++ b/tests/modules/services/mpdris2/basic-configuration.service @@ -0,0 +1,13 @@ +[Install] +WantedBy=default.target + +[Service] +BusName=org.mpris.MediaPlayer2.mpd +ExecStart=@mpdris2@/bin/mpDris2 +Restart=on-failure +RestartSec=5s +Type=simple + +[Unit] +After=mpd.service +Description=MPRIS 2 support for MPD diff --git a/tests/modules/services/mpdris2/default.nix b/tests/modules/services/mpdris2/default.nix new file mode 100644 index 000000000..eaf6be337 --- /dev/null +++ b/tests/modules/services/mpdris2/default.nix @@ -0,0 +1,4 @@ +{ + mpdris2-basic-configuration = ./basic-configuration.nix; + mpdris2-with-password = ./with-password.nix; +} diff --git a/tests/modules/services/mpdris2/with-password.config b/tests/modules/services/mpdris2/with-password.config new file mode 100644 index 000000000..939a40589 --- /dev/null +++ b/tests/modules/services/mpdris2/with-password.config @@ -0,0 +1,9 @@ +[Bling] +mmkeys = False +notify = False + +[Connection] +host = somehost +music_dir = /home/hm-user/music +password = foo +port = 42 diff --git a/tests/modules/services/mpdris2/with-password.nix b/tests/modules/services/mpdris2/with-password.nix new file mode 100644 index 000000000..fcfe15315 --- /dev/null +++ b/tests/modules/services/mpdris2/with-password.nix @@ -0,0 +1,22 @@ +{ ... }: + +{ + services.mpdris2 = { + enable = true; + mpd = { + host = "somehost"; + port = 42; + password = "foo"; + }; + }; + + test.stubs.mpdris2 = { }; + + nmt.script = '' + serviceFile=home-files/.config/systemd/user/mpdris2.service + assertFileContent "$serviceFile" ${./basic-configuration.service} + + configFile=home-files/.config/mpDris2/mpDris2.conf + assertFileContent "$configFile" ${./with-password.config} + ''; +}