clanLib.jsonschema: move tests from pkgs/clan-cli
All checks were successful
build / test (pull_request) Successful in 26s
All checks were successful
build / test (pull_request) Successful in 26s
This commit is contained in:
parent
9438a9eb5f
commit
7262208a4c
|
@ -22,6 +22,7 @@
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
];
|
];
|
||||||
imports = [
|
imports = [
|
||||||
|
# ./checks/flake-module.nix
|
||||||
./devShell.nix
|
./devShell.nix
|
||||||
./formatter.nix
|
./formatter.nix
|
||||||
./templates/flake-module.nix
|
./templates/flake-module.nix
|
||||||
|
|
|
@ -12,5 +12,5 @@
|
||||||
)
|
)
|
||||||
(builtins.readDir folder);
|
(builtins.readDir folder);
|
||||||
|
|
||||||
jsonschema = import ./jsonschema.nix { inherit lib; };
|
jsonschema = import ./jsonschema { inherit lib; };
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
{ lib
|
{ lib
|
||||||
, ...
|
, ...
|
||||||
}: {
|
}: {
|
||||||
|
imports = [
|
||||||
|
./jsonschema/flake-module.nix
|
||||||
|
];
|
||||||
flake.lib = import ./default.nix { inherit lib; };
|
flake.lib = import ./default.nix { inherit lib; };
|
||||||
}
|
}
|
||||||
|
|
29
lib/jsonschema/flake-module.nix
Normal file
29
lib/jsonschema/flake-module.nix
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
perSystem = { pkgs, self', ... }: {
|
||||||
|
checks = {
|
||||||
|
|
||||||
|
# check if the `clan config` example jsonschema and data is valid
|
||||||
|
lib-jsonschema-example-valid = pkgs.runCommand "lib-jsonschema-example-valid" { } ''
|
||||||
|
echo "Checking that example-schema.json is valid"
|
||||||
|
${pkgs.check-jsonschema}/bin/check-jsonschema \
|
||||||
|
--check-metaschema ${./.}/example-schema.json
|
||||||
|
|
||||||
|
echo "Checking that example-data.json is valid according to example-schema.json"
|
||||||
|
${pkgs.check-jsonschema}/bin/check-jsonschema \
|
||||||
|
--schemafile ${./.}/example-schema.json \
|
||||||
|
${./.}/example-data.json
|
||||||
|
|
||||||
|
touch $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
# check if the `clan config` nix jsonschema converter unit tests succeed
|
||||||
|
lib-jsonschema-nix-unit-tests = pkgs.runCommand "lib-jsonschema-nix-unit-tests" { } ''
|
||||||
|
export NIX_PATH=nixpkgs=${pkgs.path}
|
||||||
|
${self'.packages.nix-unit}/bin/nix-unit \
|
||||||
|
${./.}/test.nix \
|
||||||
|
--eval-store $(realpath .)
|
||||||
|
touch $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
# run these tests via `nix-unit ./test.nix`
|
# run these tests via `nix-unit ./test.nix`
|
||||||
{ lib ? (import <nixpkgs> { }).lib
|
{ lib ? (import <nixpkgs> { }).lib
|
||||||
, slib ? import ../../clan_cli/config/schema-lib.nix { inherit lib; }
|
, slib ? import ./. { inherit lib; }
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
parseOption = import ./test_parseOption.nix { inherit lib slib; };
|
parseOption = import ./test_parseOption.nix { inherit lib slib; };
|
|
@ -1,7 +1,7 @@
|
||||||
# tests for the nixos options to jsonschema converter
|
# tests for the nixos options to jsonschema converter
|
||||||
# run these tests via `nix-unit ./test.nix`
|
# run these tests via `nix-unit ./test.nix`
|
||||||
{ lib ? (import <nixpkgs> { }).lib
|
{ lib ? (import <nixpkgs> { }).lib
|
||||||
, slib ? import ../../../../lib/jsonschema.nix { inherit lib; }
|
, slib ? import ./. { inherit lib; }
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
description = "Test Description";
|
description = "Test Description";
|
|
@ -1,7 +1,7 @@
|
||||||
# tests for the nixos options to jsonschema converter
|
# tests for the nixos options to jsonschema converter
|
||||||
# run these tests via `nix-unit ./test.nix`
|
# run these tests via `nix-unit ./test.nix`
|
||||||
{ lib ? (import <nixpkgs> { }).lib
|
{ lib ? (import <nixpkgs> { }).lib
|
||||||
, slib ? import ../../../../lib/jsonschema.nix { inherit lib; }
|
, slib ? import ./. { inherit lib; }
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
evaledOptions =
|
evaledOptions =
|
|
@ -27,30 +27,7 @@
|
||||||
## End optional dependencies
|
## End optional dependencies
|
||||||
};
|
};
|
||||||
|
|
||||||
checks = self'.packages.clan-cli.tests // {
|
checks = self'.packages.clan-cli.tests;
|
||||||
# check if the `clan config` example jsonschema and data is valid
|
|
||||||
clan-config-example-schema-valid = pkgs.runCommand "clan-config-example-schema-valid" { } ''
|
|
||||||
echo "Checking that example-schema.json is valid"
|
|
||||||
${pkgs.check-jsonschema}/bin/check-jsonschema \
|
|
||||||
--check-metaschema ${./.}/tests/config/example-schema.json
|
|
||||||
|
|
||||||
echo "Checking that example-data.json is valid according to example-schema.json"
|
|
||||||
${pkgs.check-jsonschema}/bin/check-jsonschema \
|
|
||||||
--schemafile ${./.}/tests/config/example-schema.json \
|
|
||||||
${./.}/tests/config/example-data.json
|
|
||||||
|
|
||||||
touch $out
|
|
||||||
'';
|
|
||||||
|
|
||||||
# check if the `clan config` nix jsonschema converter unit tests succeed
|
|
||||||
clan-config-nix-unit-tests = pkgs.runCommand "clan-edit-unit-tests" { } ''
|
|
||||||
export NIX_PATH=nixpkgs=${pkgs.path}
|
|
||||||
${self'.packages.nix-unit}/bin/nix-unit \
|
|
||||||
${./.}/tests/config/test.nix \
|
|
||||||
--eval-store $(realpath .)
|
|
||||||
touch $out
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user