From 10f5a0cc4b98c61298a8d130185a25032e9fe3b8 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Wed, 17 Sep 2025 00:01:05 -0500 Subject: [PATCH] tests/oh-my-posh: expand test coverage Cover some more scenarios with the module. Signed-off-by: Austin Horstman --- .../oh-my-posh/assertion-all-three.nix | 14 +++++++ .../assertion-settings-config-file.nix | 13 +++++++ .../oh-my-posh/assertion-settings-theme.nix | 13 +++++++ .../assertion-theme-config-file.nix | 11 ++++++ .../programs/oh-my-posh/config-file.nix | 17 ++++++++ tests/modules/programs/oh-my-posh/default.nix | 6 +++ .../modules/programs/oh-my-posh/settings.nix | 39 +++++++++++++++++++ 7 files changed, 113 insertions(+) create mode 100644 tests/modules/programs/oh-my-posh/assertion-all-three.nix create mode 100644 tests/modules/programs/oh-my-posh/assertion-settings-config-file.nix create mode 100644 tests/modules/programs/oh-my-posh/assertion-settings-theme.nix create mode 100644 tests/modules/programs/oh-my-posh/assertion-theme-config-file.nix create mode 100644 tests/modules/programs/oh-my-posh/config-file.nix create mode 100644 tests/modules/programs/oh-my-posh/settings.nix diff --git a/tests/modules/programs/oh-my-posh/assertion-all-three.nix b/tests/modules/programs/oh-my-posh/assertion-all-three.nix new file mode 100644 index 000000000..5dcb22f1b --- /dev/null +++ b/tests/modules/programs/oh-my-posh/assertion-all-three.nix @@ -0,0 +1,14 @@ +{ + programs.oh-my-posh = { + enable = true; + settings = { + version = 2; + }; + useTheme = "jandedobbeleer"; + configFile = "/etc/oh-my-posh/custom.json"; + }; + + test.asserts.assertions.expected = [ + "oh-my-posh: Only one of 'settings', 'useTheme', or 'configFile' can be configured at a time." + ]; +} diff --git a/tests/modules/programs/oh-my-posh/assertion-settings-config-file.nix b/tests/modules/programs/oh-my-posh/assertion-settings-config-file.nix new file mode 100644 index 000000000..a988281df --- /dev/null +++ b/tests/modules/programs/oh-my-posh/assertion-settings-config-file.nix @@ -0,0 +1,13 @@ +{ + programs.oh-my-posh = { + enable = true; + settings = { + version = 2; + }; + configFile = "/etc/oh-my-posh/custom.json"; + }; + + test.asserts.assertions.expected = [ + "oh-my-posh: Only one of 'settings', 'useTheme', or 'configFile' can be configured at a time." + ]; +} diff --git a/tests/modules/programs/oh-my-posh/assertion-settings-theme.nix b/tests/modules/programs/oh-my-posh/assertion-settings-theme.nix new file mode 100644 index 000000000..77152c909 --- /dev/null +++ b/tests/modules/programs/oh-my-posh/assertion-settings-theme.nix @@ -0,0 +1,13 @@ +{ + programs.oh-my-posh = { + enable = true; + settings = { + version = 2; + }; + useTheme = "jandedobbeleer"; + }; + + test.asserts.assertions.expected = [ + "oh-my-posh: Only one of 'settings', 'useTheme', or 'configFile' can be configured at a time." + ]; +} diff --git a/tests/modules/programs/oh-my-posh/assertion-theme-config-file.nix b/tests/modules/programs/oh-my-posh/assertion-theme-config-file.nix new file mode 100644 index 000000000..6baec21ac --- /dev/null +++ b/tests/modules/programs/oh-my-posh/assertion-theme-config-file.nix @@ -0,0 +1,11 @@ +{ + programs.oh-my-posh = { + enable = true; + useTheme = "jandedobbeleer"; + configFile = "/etc/oh-my-posh/custom.json"; + }; + + test.asserts.assertions.expected = [ + "oh-my-posh: Only one of 'settings', 'useTheme', or 'configFile' can be configured at a time." + ]; +} diff --git a/tests/modules/programs/oh-my-posh/config-file.nix b/tests/modules/programs/oh-my-posh/config-file.nix new file mode 100644 index 000000000..8e7c28fa1 --- /dev/null +++ b/tests/modules/programs/oh-my-posh/config-file.nix @@ -0,0 +1,17 @@ +{ + programs = { + bash.enable = true; + + oh-my-posh = { + enable = true; + configFile = "/etc/oh-my-posh/custom.json"; + }; + }; + + nmt.script = '' + assertFileExists home-files/.bashrc + assertFileContains \ + home-files/.bashrc \ + '/bin/oh-my-posh init bash --config /etc/oh-my-posh/custom.json' + ''; +} diff --git a/tests/modules/programs/oh-my-posh/default.nix b/tests/modules/programs/oh-my-posh/default.nix index 4b4c9f46f..eaac1e52d 100644 --- a/tests/modules/programs/oh-my-posh/default.nix +++ b/tests/modules/programs/oh-my-posh/default.nix @@ -3,4 +3,10 @@ oh-my-posh-zsh = ./zsh.nix; oh-my-posh-fish = ./fish.nix; oh-my-posh-nushell = ./nushell.nix; + oh-my-posh-settings = ./settings.nix; + oh-my-posh-config-file = ./config-file.nix; + oh-my-posh-assertion-settings-theme = ./assertion-settings-theme.nix; + oh-my-posh-assertion-settings-config-file = ./assertion-settings-config-file.nix; + oh-my-posh-assertion-theme-config-file = ./assertion-theme-config-file.nix; + oh-my-posh-assertion-all-three = ./assertion-all-three.nix; } diff --git a/tests/modules/programs/oh-my-posh/settings.nix b/tests/modules/programs/oh-my-posh/settings.nix new file mode 100644 index 000000000..51ac2b555 --- /dev/null +++ b/tests/modules/programs/oh-my-posh/settings.nix @@ -0,0 +1,39 @@ +{ + programs = { + bash.enable = true; + + oh-my-posh = { + enable = true; + settings = { + version = 2; + final_space = true; + blocks = [ + { + type = "prompt"; + alignment = "left"; + segments = [ + { + type = "shell"; + style = "plain"; + template = "{{ .Name }} "; + } + ]; + } + ]; + }; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/oh-my-posh/config.json + assertFileContains \ + home-files/.config/oh-my-posh/config.json \ + '"version": 2' + assertFileContains \ + home-files/.config/oh-my-posh/config.json \ + '"final_space": true' + assertFileContains \ + home-files/.bashrc \ + '/bin/oh-my-posh init bash --config /home/hm-user/.config/oh-my-posh/config.json' + ''; +}