lazy.nvim.nix/tests/lazyUtils.nix

69 lines
1.6 KiB
Nix
Raw Permalink Normal View History

{ lazyUtils }:
let
nullPlugin = {
name = null;
short = null;
dir = null;
};
miniDrv = builtins.derivation {
name = "test";
pname = "test";
builder = "test";
system = "test";
};
in
{
helpers = {
getName = {
testName = {
expr = lazyUtils.helpers.getName (nullPlugin // { name = "nameTest"; });
expected = "nameTest";
};
testShort = {
expr = lazyUtils.helpers.getName (nullPlugin // { short = "shortTest"; });
expected = "shortTest";
};
testDir = {
expr = lazyUtils.helpers.getName (nullPlugin // { dir = ./empty.txt; });
expected = "empty.txt";
};
testDrv = {
expr = lazyUtils.helpers.getName (nullPlugin // { dir = miniDrv; });
expected = "test";
};
testInvalidInput = {
expr = lazyUtils.helpers.getName { };
expectedError = {
type = "ThrownError";
# For some reason there is whitespace after the newline
msg = "Could not determine a plugin name.\n +\\{\\}";
};
};
};
getKey = { };
pluginWrapper = {
testShort = {
expr = lazyUtils.helpers.pluginWrapper "test";
expected = {
short = "test";
};
};
testDrv = {
expr = lazyUtils.helpers.pluginWrapper miniDrv;
expected = {
dir = miniDrv;
};
};
testSet = {
expr = lazyUtils.helpers.pluginWrapper { };
expected = { };
};
testInvalidInput = {
expr = lazyUtils.helpers.pluginWrapper null;
expectedError.type = "AssertionError";
};
};
};
}