mirror of
https://gitlab.com/TECHNOFAB/nixlets.git
synced 2026-02-02 03:05:09 +01:00
feat: switch from flake-parts & devenv to rensa + add nixtest
This commit is contained in:
parent
6af83809f7
commit
012a3afb2d
18 changed files with 553 additions and 611 deletions
6
tests/fixtures/example/nixlet.nix
vendored
Normal file
6
tests/fixtures/example/nixlet.nix
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
name = "example";
|
||||
version = "0.0.1";
|
||||
description = "hello world";
|
||||
defaultProject = "example";
|
||||
}
|
||||
12
tests/fixtures/example/values.nix
vendored
Normal file
12
tests/fixtures/example/values.nix
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{lib, ...}:
|
||||
with lib; {
|
||||
options = {
|
||||
example = mkOption {
|
||||
type = types.str;
|
||||
default = "Hello world!";
|
||||
description = ''
|
||||
Some description.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
47
tests/lib_test.nix
Normal file
47
tests/lib_test.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
pkgs,
|
||||
ntlib,
|
||||
nixlet-lib,
|
||||
...
|
||||
}: {
|
||||
suites."Lib Tests" = {
|
||||
pos = __curPos;
|
||||
tests = let
|
||||
nixlet = nixlet-lib.mkNixlet ./fixtures/example;
|
||||
in [
|
||||
{
|
||||
name = "mkNixlet fail on nonexistant nixlet.nix";
|
||||
expected = {
|
||||
success = false;
|
||||
value = false;
|
||||
};
|
||||
actual = builtins.tryEval (nixlet-lib.mkNixlet "/nonexistant").name;
|
||||
}
|
||||
{
|
||||
name = "mkNixlet success";
|
||||
expected = {
|
||||
name = "example";
|
||||
version = "0.0.1";
|
||||
description = "hello world";
|
||||
};
|
||||
actual = {inherit (nixlet) name description version;};
|
||||
}
|
||||
{
|
||||
name = "Nixlet mkDocs";
|
||||
type = "script";
|
||||
script = let
|
||||
docs = nixlet.mkDocs {};
|
||||
in
|
||||
# sh
|
||||
''
|
||||
${ntlib.helpers.path [pkgs.gnugrep]}
|
||||
${ntlib.helpers.scriptHelpers}
|
||||
assert "-f ${docs}" "generated the file"
|
||||
assert_file_contains "${docs}" '`example`'
|
||||
assert_file_contains "${docs}" "Some description."
|
||||
assert_file_contains "${docs}" '"Hello world!"'
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
30
tests/render_test.nix
Normal file
30
tests/render_test.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
pkgs,
|
||||
ntlib,
|
||||
system,
|
||||
nixlets,
|
||||
...
|
||||
}: {
|
||||
suites."Render Tests" = {
|
||||
pos = __curPos;
|
||||
tests = builtins.map (
|
||||
nixlet: {
|
||||
name = "render ${nixlet.name}";
|
||||
type = "script";
|
||||
script = let
|
||||
output = nixlet.render {inherit system;};
|
||||
in
|
||||
# sh
|
||||
''
|
||||
${ntlib.helpers.path [pkgs.gnugrep]}
|
||||
${ntlib.helpers.scriptHelpers}
|
||||
|
||||
assert "-f ${output}" "should render"
|
||||
assert_file_contains "${output}" "apiVersion"
|
||||
assert_file_contains "${output}" "kubenix/k8s-version"
|
||||
assert_file_contains "${output}" "kubenix/project-name"
|
||||
'';
|
||||
}
|
||||
) (builtins.attrValues nixlets);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue