From 76d6dbb1d88d4fba373fa5b8d87ba368104dd26d Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sat, 13 Jul 2024 17:00:06 +0800 Subject: [PATCH] wrapper-manager-fds/tests: init derivation for tests This is to make checking with flakes a bit easier. Though, there are much better ways to integrate this even with just the nix-command experimental feature. --- tests/default.nix | 18 ++++++++++++++---- tests/lib/tests.schema.json | 16 ++++++++++++++++ tests/lib/utils.nix | 8 ++++---- 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 tests/lib/tests.schema.json diff --git a/tests/default.nix b/tests/default.nix index 539c82d..bea8479 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -1,9 +1,19 @@ -{ branch ? "nixos-stable" }: - let sources = import ../npins; - pkgs = import sources.${branch} { }; +in +{ pkgs ? import sources.nixos-unstable { } }: + +let + lib = import ./lib { inherit pkgs; }; in { - lib = import ./lib { inherit pkgs; }; + inherit lib; + libTestPkg = + pkgs.runCommand "wrapper-manager-fds-lib-test" { + testData = builtins.toJSON lib; + passAsFile = [ "testData" ]; + nativeBuildInputs = with pkgs; [ yajsv jq ]; + } '' + yajsv -s "${./lib/tests.schema.json}" "$testDataPath" && touch $out || jq . "$testDataPath" + ''; } diff --git a/tests/lib/tests.schema.json b/tests/lib/tests.schema.json new file mode 100644 index 0000000..d1e97e1 --- /dev/null +++ b/tests/lib/tests.schema.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "wrapper-manager-fds Nix test object", + "type": "object", + "patternProperties": { + "^\\w+$": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 0, + "maxItems": 0 + }, + "required": true + } +} diff --git a/tests/lib/utils.nix b/tests/lib/utils.nix index 8f78494..76d7f97 100644 --- a/tests/lib/utils.nix +++ b/tests/lib/utils.nix @@ -3,22 +3,22 @@ lib.runTests { testsUtilsGetBin = { expr = self.utils.getBin [ - ../modules + ../../lib ../../modules ]; expected = [ - (lib.getBin ../modules) + (lib.getBin ../../lib) (lib.getBin ../../modules) ]; }; testsUtilsGetLibexec = { expr = self.utils.getLibexec [ - ../modules + ../../lib ../../modules ]; expected = [ - "${../modules}/libexec" + "${../../lib}/libexec" "${../../modules}/libexec" ]; };