mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 06:19:00 +00:00
bahaghari/tests: add tests derivation for flake output
Also a schema to check if the whole test suite passes which is nice.
This commit is contained in:
parent
ad32539742
commit
9c69e03395
@ -39,8 +39,15 @@
|
||||
)
|
||||
);
|
||||
in eachSystem systems
|
||||
(system: {
|
||||
(system: let
|
||||
tests = branch: import ./tests { inherit branch system; };
|
||||
in {
|
||||
devShells.default =
|
||||
import ./shell.nix { pkgs = import sources.nixos-stable { inherit system; }; };
|
||||
|
||||
checks = {
|
||||
bahaghariLibStable = (tests "stable").libTestPkg;
|
||||
bahaghariLibUnstable = (tests "unstable").libTestPkg;
|
||||
};
|
||||
}) // import ./default.nix { };
|
||||
}
|
||||
|
@ -1,11 +1,27 @@
|
||||
# This is the unit cases for our Nix project.
|
||||
{ branch ? "nixos-stable" }:
|
||||
# This is the unit cases for our Nix project. It should only require a nixpkgs
|
||||
# instance and we'll have to make it easy to test between the unstable and
|
||||
# stable version of home-manager and NixOS.
|
||||
{ branch ? "stable", system ? builtins.currentSystem }:
|
||||
|
||||
let
|
||||
sources = import ../npins;
|
||||
pkgs = import sources.${branch} { };
|
||||
pkgs = import sources."nixos-${branch}" { inherit system; };
|
||||
bahaghariLib = import ./lib { inherit pkgs; };
|
||||
in
|
||||
{
|
||||
lib = import ./lib { inherit pkgs; };
|
||||
lib = bahaghariLib;
|
||||
libTestPkg =
|
||||
pkgs.runCommand "bahaghari-lib-test"
|
||||
{
|
||||
testData = builtins.toJSON bahaghariLib;
|
||||
passAsFile = [ "testData" ];
|
||||
nativeBuildInputs = with pkgs; [
|
||||
yajsv
|
||||
jq
|
||||
];
|
||||
}
|
||||
''
|
||||
yajsv -s "${./lib/tests.schema.json}" "$testDataPath" && touch $out || jq . "$testDataPath"
|
||||
'';
|
||||
#modules = import ./modules { inherit pkgs; };
|
||||
}
|
||||
|
16
subprojects/bahaghari/tests/lib/tests.schema.json
Normal file
16
subprojects/bahaghari/tests/lib/tests.schema.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"title": "nix-lib-bahaghari Nix test object",
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^\\w+$": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"minItems": 0,
|
||||
"maxItems": 0
|
||||
},
|
||||
"required": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user