Files
.github
datadog
doc
examples
foreman
src
t
Event
Hydra
Config
Controller
Admin
Build
Jobset
JobsetEval
Root
evals.t
narinfo.t
queue-runner-status.t
metrics.t
projects.t
Event
Helper
Plugin
Schema
View
Event.t
Math.t
PostgresListener.t
TaskDispatcher.t
input-types
jobs
lib
queue-runner
scripts
Makefile.am
api-test.t
build-products.t
evaluate-basic.t
evaluate-dependent-jobsets.t
perlcritic.pl
s3-backup-test.config
s3-backup-test.pl
setup-notifications-jobset.pl
test.pl
.editorconfig
.gitignore
.perlcriticrc
.yath.rc
COPYING
INSTALL
Makefile.am
Procfile
README.md
bootstrap
configure.ac
default.nix
flake.lock
flake.nix
hydra-api.yaml
hydra-module.nix
shell.nix
version.txt
hydra/t/Hydra/Controller/Root/narinfo.t
Graham Christensen a5d1d36fa6 Tests: restructure to more closely mirror the sources
t/ had lots of directories and files mirroring src/lib/Hydra. This moves
those files under t/Hydra
2022-01-10 15:34:52 -05:00

49 lines
1.7 KiB
Perl

use strict;
use warnings;
use Setup;
use Data::Dumper;
use JSON::MaybeXS qw(decode_json);
my %ctx = test_init(
# Without this, the test will fail because a `file:` store is not treated as a
# local store by `isLocalStore` in src/lib/Hydra/Helper/Nix.pm, and any
# requests to /HASH.narinfo will fail.
use_external_destination_store => 0
);
require Hydra::Schema;
require Hydra::Model::DB;
require Hydra::Helper::Nix;
use Test2::V0;
require Catalyst::Test;
use HTTP::Request::Common;
Catalyst::Test->import('Hydra');
my $db = Hydra::Model::DB->new;
hydra_setup($db);
my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"});
my $jobset = createBaseJobset("basic", "basic.nix", $ctx{jobsdir});
ok(evalSucceeds($jobset), "Evaluating jobs/basic.nix should exit with return code 0");
for my $build (queuedBuildsForJobset($jobset)) {
ok(runBuild($build), "Build '".$build->job."' from jobs/basic.nix should exit with return code 0");
}
subtest "/HASH.narinfo" => sub {
my $build_redirect = request(GET '/job/tests/basic/empty_dir/latest-finished');
my $url = URI->new($build_redirect->header('location'))->path;
my $json = request(GET $url, Accept => 'application/json');
my $data = decode_json($json->content);
my $outpath = $data->{buildoutputs}{out}{path};
my ($hash) = $outpath =~ qr{/nix/store/([a-z0-9]{32}).*};
my $narinfo_response = request(GET "/$hash.narinfo");
ok($narinfo_response->is_success, "Getting the narinfo of a build");
my ($storepath) = $narinfo_response->content =~ qr{StorePath: (.*)};
is($storepath, $outpath, "The returned store path is the same as the out path")
};
done_testing;