2021-11-22 18:14:01 +00:00
|
|
|
use feature 'unicode_strings';
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Setup;
|
|
|
|
use Test2::V0;
|
|
|
|
|
2021-12-08 18:31:34 +00:00
|
|
|
my $ctx = test_context();
|
2021-11-22 18:14:01 +00:00
|
|
|
|
2021-12-08 18:31:34 +00:00
|
|
|
require Hydra; # calls setup()
|
|
|
|
require Hydra::View::TT;
|
|
|
|
require Catalyst::Test;
|
2021-11-22 18:14:01 +00:00
|
|
|
|
2021-12-08 18:31:34 +00:00
|
|
|
my $db = $ctx->db;
|
2021-11-22 18:14:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
# The following lines are a cheap and hacky trick to get $c,
|
|
|
|
# there is no other reason to call /.
|
|
|
|
Catalyst::Test->import('Hydra');
|
2021-12-01 18:46:58 +00:00
|
|
|
my ($_request, $c) = ctx_request('/');
|
2021-11-22 18:14:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"});
|
2021-12-08 18:31:34 +00:00
|
|
|
my $jobset = createBaseJobset("example", "bogus.nix", $ctx->jobsdir);
|
2021-11-22 18:14:01 +00:00
|
|
|
my $job = "myjob";
|
|
|
|
|
|
|
|
|
|
|
|
is(
|
|
|
|
Hydra::View::TT::linkToProject(undef, $c, $project),
|
|
|
|
'<a href="http://localhost/project/tests">tests</a>',
|
|
|
|
"linkToProject"
|
|
|
|
);
|
|
|
|
is(
|
|
|
|
Hydra::View::TT::linkToJobset(undef, $c, $jobset),
|
2021-11-22 21:00:58 +00:00
|
|
|
'<a href="http://localhost/project/tests">tests</a>'
|
|
|
|
. ':<a href="http://localhost/jobset/tests/example">example</a>',
|
2021-11-22 18:14:01 +00:00
|
|
|
"linkToJobset"
|
|
|
|
);
|
|
|
|
is(
|
|
|
|
Hydra::View::TT::linkToJob(undef, $c, $jobset, $job),
|
2021-11-22 21:00:58 +00:00
|
|
|
'<a href="http://localhost/project/tests">tests</a>'
|
|
|
|
. ':<a href="http://localhost/jobset/tests/example">example</a>'
|
|
|
|
. ':<a href="http://localhost/job/tests/example/myjob">myjob</a>',
|
2021-11-22 18:14:01 +00:00
|
|
|
"linkToJob"
|
|
|
|
);
|
|
|
|
|
|
|
|
is(
|
|
|
|
Hydra::View::TT::makeNameLinksForJobset(undef, $c, $jobset),
|
|
|
|
'<a href="http://localhost/project/tests">tests</a>'
|
|
|
|
. ':example',
|
|
|
|
"makeNameLinksForJobset"
|
|
|
|
);
|
|
|
|
is(
|
|
|
|
Hydra::View::TT::makeNameLinksForJob(undef, $c, $jobset, $job),
|
2021-11-22 21:00:58 +00:00
|
|
|
'<a href="http://localhost/project/tests">tests</a>'
|
|
|
|
. ':<a href="http://localhost/jobset/tests/example">example</a>'
|
2021-11-22 18:14:01 +00:00
|
|
|
. ':myjob',
|
|
|
|
"makeNameLinksForJob"
|
|
|
|
);
|
|
|
|
|
|
|
|
is(
|
|
|
|
Hydra::View::TT::makeNameTextForJobset(undef, $c, $jobset),
|
|
|
|
'tests:example',
|
|
|
|
"makeNameTextForJobset"
|
|
|
|
);
|
|
|
|
is(
|
|
|
|
Hydra::View::TT::makeNameTextForJob(undef, $c, $jobset, $job),
|
|
|
|
'tests:example:myjob',
|
|
|
|
"makeNameTextForJob"
|
|
|
|
);
|
|
|
|
|
|
|
|
done_testing;
|