improve testing

This commit is contained in:
Jaka Hudoklin 2019-05-05 11:55:19 +02:00
parent e4493addd8
commit 7e7eb19e94
No known key found for this signature in database
GPG key ID: 916062A1C4748647
6 changed files with 55 additions and 35 deletions

View file

@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> {}, nixosPath ? <nixpkgs/nixos>, lib ? pkgs.lib
{ pkgs ? import <nixpkgs> {}, nixosPath ? toString <nixpkgs/nixos>, lib ? pkgs.lib
, e2e ? true, throwError ? true }:
with lib;
@ -19,9 +19,11 @@ let
inherit (pkgs) lib;
};
runK8STests = k8sVersion: pkgs.recurseIntoAttrs (import ./tests {
inherit pkgs lib kubenix k8sVersion e2e throwError nixosPath;
});
runK8STests = k8sVersion: pkgs.recurseIntoAttrs (getAttrs ["result" "results" "success"]
(import ./tests {
inherit pkgs lib kubenix k8sVersion e2e throwError nixosPath;
})
);
in rec {
generate.k8s = pkgs.linkFarm "k8s-generated.nix" [{
name = "v1.7.nix";
@ -86,7 +88,7 @@ in rec {
path = generateIstio;
}];
tests = {
tests = pkgs.recurseIntoAttrs {
k8s-1_7 = runK8STests "1.7";
k8s-1_8 = runK8STests "1.8";
k8s-1_9 = runK8STests "1.9";
@ -96,13 +98,8 @@ in rec {
k8s-1_13 = runK8STests "1.13";
};
test-results = pkgs.writeText "kubenix-test-result.json" (builtins.toJSON {
success = all (test: test.success) (attrValues tests);
results = mapAttrs (_: test: test.result) tests;
});
test-check =
if !(all (test: test.success) (attrValues tests))
if !(all (test: if isAttrs test then test.success else true) (attrValues tests))
then throw "tests failed"
else true;