1
0
Fork 0

refactor tests to remove boilerplate

This commit is contained in:
ibizaman 2023-03-07 00:36:05 -08:00
parent ef7d2d2dd5
commit 130915784e
2 changed files with 40 additions and 30 deletions

View file

@ -12,14 +12,17 @@ let
tar xfvj ${tarball}/tarballs/*.tar.bz2 --strip-components=1 tar xfvj ${tarball}/tarballs/*.tar.bz2 --strip-components=1
''; '';
}; };
in
{ disnixos = import "${pkgs.disnixos}/share/disnixos/testing.nix" {
inherit nixpkgs;
};
# We need this function because, for a reason that eludes me, the # We need this function because, for a reason that eludes me, the
# one defined in disnixos fails the name attribute not correctly set # one defined in disnixos fails the name attribute not correctly set
# in the call to simpleTest. The only difference between this # in the call to simpleTest. The only difference between this
# function and the one in disnixos is the additional `inherit name` # function and the one in disnixos is the additional `inherit name`
# line. # line.
disnixTest = system: customDisnixTest = system:
{name, manifest, tarball, networkFile, externalNetworkFile ? false, testScript, dysnomiaStateDir ? "", postActivateTimeout ? 1}: {name, manifest, tarball, networkFile, externalNetworkFile ? false, testScript, dysnomiaStateDir ? "", postActivateTimeout ? 1}:
let let
@ -42,4 +45,24 @@ in
manifestFile = "${manifest}/manifest.xml"; manifestFile = "${manifest}/manifest.xml";
}; };
}; };
in
{
inherit (disnixos) sourceTarball;
genBuilds = systems: config:
pkgs.lib.genAttrs systems (system:
let
pkgs = import nixpkgs { inherit system; };
disnixos = import "${pkgs.disnixos}/share/disnixos/testing.nix" {
inherit nixpkgs system;
};
in
disnixos.buildManifest config
);
disnixTest = currentSystem: manifest: config:
customDisnixTest currentSystem (config // {
manifest = builtins.getAttr currentSystem manifest;
});
} }

View file

@ -1,3 +1,4 @@
# Run tests with nix-build -A tests.integration.keycloak
{ nixpkgs ? <nixpkgs> { nixpkgs ? <nixpkgs>
, systems ? [ "i686-linux" "x86_64-linux" ] , systems ? [ "i686-linux" "x86_64-linux" ]
}: }:
@ -5,13 +6,9 @@
let let
pkgs = import nixpkgs {}; pkgs = import nixpkgs {};
disnixos = import "${pkgs.disnixos}/share/disnixos/testing.nix" {
inherit nixpkgs;
};
version = "1.0"; version = "1.0";
disnixos2 = pkgs.callPackage ./common.nix { inherit nixpkgs; }; disnixos = pkgs.callPackage ./common.nix { inherit nixpkgs; };
in in
rec { rec {
@ -23,33 +20,23 @@ rec {
}; };
builds = { builds = {
simple = pkgs.lib.genAttrs systems (system: simple = disnixos.genBuilds systems {
let name = "test-project-manifest";
pkgs = import nixpkgs { inherit system; }; inherit version;
inherit tarball;
disnixos = import "${pkgs.disnixos}/share/disnixos/testing.nix" { servicesFile = "tests/integration/keycloak/services.nix";
inherit nixpkgs system; networkFile = "tests/integration/keycloak/network.nix";
}; distributionFile = "tests/integration/keycloak/distribution.nix";
in # extraParams = {
disnixos.buildManifest { # "extra-builtins-file" = ../../extra-builtins.nix;
name = "test-project-manifest"; # };
inherit version; };
inherit tarball;
servicesFile = "tests/integration/keycloak/services.nix";
networkFile = "tests/integration/keycloak/network.nix";
distributionFile = "tests/integration/keycloak/distribution.nix";
# extraParams = {
# "extra-builtins-file" = ../../extra-builtins.nix;
# };
}
);
}; };
tests = { tests = {
simple = disnixos2.disnixTest builtins.currentSystem { simple = disnixos.disnixTest builtins.currentSystem builds.simple {
name = "test-project-test"; name = "test-project-test";
inherit tarball; inherit tarball;
manifest = builtins.getAttr (builtins.currentSystem) builds.simple;
networkFile = "tests/integration/keycloak/network.nix"; networkFile = "tests/integration/keycloak/network.nix";
# dysnomiaStateDir = /var/state/dysnomia; # dysnomiaStateDir = /var/state/dysnomia;
testScript = testScript =