mirror of
https://github.com/nix-community/nixvim.git
synced 2025-11-21 17:59:41 +01:00
tests/enable-except-in-tests: refactor
More explicitly assert that `enableExceptInTests` is the expected value.
This commit is contained in:
parent
770743284b
commit
7add68e918
1 changed files with 45 additions and 13 deletions
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
linkFarm,
|
||||
runCommandLocal,
|
||||
|
|
@ -6,30 +7,61 @@
|
|||
makeNixvimWithModule,
|
||||
}:
|
||||
let
|
||||
module =
|
||||
{ helpers, ... }:
|
||||
{
|
||||
plugins.image.enable = helpers.enableExceptInTests;
|
||||
};
|
||||
|
||||
inTest = mkTestDerivationFromNixvimModule {
|
||||
name = "enable-except-in-tests-test";
|
||||
inherit pkgs module;
|
||||
inherit pkgs;
|
||||
module =
|
||||
{ lib, helpers, ... }:
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
# FIXME: should be false
|
||||
assertion = lib.nixvim.enableExceptInTests;
|
||||
message = "Expected lib.nixvim.enableExceptInTests to be true";
|
||||
}
|
||||
{
|
||||
assertion = !helpers.enableExceptInTests;
|
||||
message = "Expected helpers.enableExceptInTests to be false";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
notInTest =
|
||||
let
|
||||
nvim = makeNixvimWithModule { inherit pkgs module; };
|
||||
nvim = makeNixvimWithModule {
|
||||
inherit pkgs;
|
||||
module =
|
||||
{ lib, helpers, ... }:
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = lib.nixvim.enableExceptInTests;
|
||||
message = "Expected lib.nixvim.enableExceptInTests to be true";
|
||||
}
|
||||
{
|
||||
assertion = helpers.enableExceptInTests;
|
||||
message = "Expected helpers.enableExceptInTests to be true";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
in
|
||||
runCommandLocal "enable-except-in-tests-not-in-test"
|
||||
{ printConfig = "${nvim}/bin/nixvim-print-init"; }
|
||||
{
|
||||
__structuredAttrs = true;
|
||||
assertions = lib.pipe nvim.config.assertions [
|
||||
(lib.filter (x: !x.assertion))
|
||||
(lib.map (x: x.message))
|
||||
];
|
||||
}
|
||||
''
|
||||
if ! "$printConfig" | grep 'require("image").setup'; then
|
||||
echo "image.nvim is not present in the configuration"
|
||||
echo -e "configuration:\n$($printConfig)"
|
||||
if (( ''${#assertions[@]} )); then
|
||||
for assertion in "''${assertions[@]}"; do
|
||||
echo "- $assertion"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
touch $out
|
||||
'';
|
||||
in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue