mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-12 18:20:07 +01:00
test: add basic test for flakeModule functionality
This commit is contained in:
parent
0952ab4145
commit
e074d716c4
7 changed files with 73 additions and 6 deletions
39
tests/flake_parts_test.nix
Normal file
39
tests/flake_parts_test.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
pkgs,
|
||||
ntlib,
|
||||
...
|
||||
}: {
|
||||
suites."flake-parts" = {
|
||||
pos = __curPos;
|
||||
tests = [
|
||||
{
|
||||
name = "flakeModule";
|
||||
type = "script";
|
||||
script =
|
||||
# sh
|
||||
''
|
||||
${ntlib.helpers.scriptHelpers}
|
||||
${ntlib.helpers.path (with pkgs; [coreutils nix gnused gnugrep jq])}
|
||||
repo_path=${../.}
|
||||
|
||||
dir=$(mktemp -d)
|
||||
trap "rm -rf $dir" EXIT
|
||||
cd $dir
|
||||
cp ${./fixtures/flake_parts}/* .
|
||||
# import from the absolute path above, is easier than trying to figure out the repo path etc.
|
||||
sed -i -e "s|@repo_path@|$repo_path|" flake.nix
|
||||
|
||||
# NOTE: --impure is required since importing modules from absolute paths is not allowed in pure mode
|
||||
nix build --impure .#gitlab-ci:pipeline:default
|
||||
assert "-f result" "should exist"
|
||||
assert_file_contains "result" "finalize_nix_ci"
|
||||
jq '.' result # check if valid json just to be sure
|
||||
|
||||
nix build --impure .#gitlab-ci:pipeline:default:pretty
|
||||
assert "-f result" "should exist"
|
||||
assert_file_contains "result" " - finalize_nix_ci"
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue