From 541874f55d7c15b4c67329ec0370b245dea322e8 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 4 Mar 2022 00:43:40 +0100 Subject: [PATCH] mpd: add basic test case --- tests/default.nix | 1 + .../services/mpd/basic-configuration.conf | 11 +++++++++++ .../services/mpd/basic-configuration.nix | 19 +++++++++++++++++++ .../services/mpd/basic-configuration.service | 13 +++++++++++++ tests/modules/services/mpd/default.nix | 1 + 5 files changed, 45 insertions(+) create mode 100644 tests/modules/services/mpd/basic-configuration.conf create mode 100644 tests/modules/services/mpd/basic-configuration.nix create mode 100644 tests/modules/services/mpd/basic-configuration.service create mode 100644 tests/modules/services/mpd/default.nix diff --git a/tests/default.nix b/tests/default.nix index 34621756..7287bc41 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -148,6 +148,7 @@ import nmt { ./modules/services/home-manager-auto-upgrade ./modules/services/kanshi ./modules/services/lieer + ./modules/services/mpd ./modules/services/pantalaimon ./modules/services/pbgopy ./modules/services/playerctld diff --git a/tests/modules/services/mpd/basic-configuration.conf b/tests/modules/services/mpd/basic-configuration.conf new file mode 100644 index 00000000..54d6059f --- /dev/null +++ b/tests/modules/services/mpd/basic-configuration.conf @@ -0,0 +1,11 @@ +music_directory "/home/hm-user/music" +playlist_directory "/home/hm-user/.local/share/mpd/playlists" +db_file "/home/hm-user/.local/share/mpd/tag_cache" + +state_file "/home/hm-user/.local/share/mpd/state" +sticker_file "/home/hm-user/.local/share/mpd/sticker.sql" + +bind_to_address "127.0.0.1" + + + diff --git a/tests/modules/services/mpd/basic-configuration.nix b/tests/modules/services/mpd/basic-configuration.nix new file mode 100644 index 00000000..c1f28898 --- /dev/null +++ b/tests/modules/services/mpd/basic-configuration.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + services.mpd.enable = true; + + test.stubs.mpd = { }; + + nmt.script = '' + serviceFile=$(normalizeStorePaths home-files/.config/systemd/user/mpd.service) + assertFileContent "$serviceFile" ${./basic-configuration.service} + + confFile=$(grep -o \ + '/nix/store/.*-mpd.conf' \ + $TESTED/home-files/.config/systemd/user/mpd.service) + assertFileContent "$confFile" ${./basic-configuration.conf} + ''; +} diff --git a/tests/modules/services/mpd/basic-configuration.service b/tests/modules/services/mpd/basic-configuration.service new file mode 100644 index 00000000..14679036 --- /dev/null +++ b/tests/modules/services/mpd/basic-configuration.service @@ -0,0 +1,13 @@ +[Install] +WantedBy=default.target + +[Service] +Environment=PATH=/home/hm-user/.nix-profile/bin +ExecStart=@mpd@/bin/mpd --no-daemon /nix/store/00000000000000000000000000000000-mpd.conf +ExecStartPre=/nix/store/00000000000000000000000000000000-bash-5.1-p12/bin/bash -c "/nix/store/00000000000000000000000000000000-coreutils-9.0/bin/mkdir -p '/home/hm-user/.local/share/mpd' '/home/hm-user/.local/share/mpd/playlists'" +Type=notify + +[Unit] +After=network.target +After=sound.target +Description=Music Player Daemon diff --git a/tests/modules/services/mpd/default.nix b/tests/modules/services/mpd/default.nix new file mode 100644 index 00000000..22d1638e --- /dev/null +++ b/tests/modules/services/mpd/default.nix @@ -0,0 +1 @@ +{ mpd-basic-configuration = ./basic-configuration.nix; }