Test setup: support arbitrary hydra config
[?]
Feb 23, 2021, 9:08 PM
4WLW4VHSOVVFNMPW3S7XVIC3MH7BSUN3FQ37LXGOJ4ODMPVGLO6ACDependencies
- [2]
UIA3ULNUGive each test its own Nix directories - [3]
OWRS526HCreate an ephemeral PostgreSQL database per test - [4]
HX4QYOYAadd first evaluations tests
Change contents
- replacement in tests/lib/Setup.pm at line 13
sub test_init() {# Set up the environment for running tests.## Hash Parameters:## * hydra_config: configuration for the Hydra processes for your test.## This clears several environment variables and sets them to ephemeral# values: a temporary database, temporary Nix store, temporary Hydra# data directory, etc.## Note: This function must run _very_ early, before nearly any Hydra# libraries are loaded. To use this, you very likely need to `use Setup`# and then run `test_init`, and then `require` the Hydra libraries you# need.## It returns a tuple: a handle to a temporary directory and a handle to# the postgres service. If either of these variables go out of scope,# those resources are released and the test environment becomes invalid.## Look at the top of an existing `.t` file to see how this should be used# in practice.sub test_init {my %opts = @_; - edit in tests/lib/Setup.pm at line 47
$ENV{'HYDRA_CONFIG'} = "$dir/hydra.conf"; - edit in tests/lib/Setup.pm at line 50
open(my $fh, '>', $ENV{'HYDRA_CONFIG'}) or die "Could not open file '" . $ENV{'HYDRA_CONFIG'}. " $!";print $fh $opts{'hydra_config'} || "";close $fh;