Commit 1ec8d3fb574f1635b1494172958cd601d54d82c4
1 parent
367add4f
Exists in
master
and in
2 other branches
add subroutine to return copr link
Showing
2 changed files
with
12 additions
and
3 deletions
Show diff stats
lib/CoprStatus.pm
... | ... | @@ -7,14 +7,19 @@ use LWP::UserAgent; |
7 | 7 | |
8 | 8 | $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; |
9 | 9 | |
10 | +sub copr_monitor_url { | |
11 | + my ( $user, $repo ) = @_; | |
12 | + return "http://copr.fedoraproject.org/api/coprs/$user/$repo/monitor/"; | |
13 | +} | |
14 | + | |
10 | 15 | sub copr_info { |
11 | 16 | my $ua = LWP::UserAgent->new; |
12 | 17 | $ua->timeout(300); |
13 | 18 | $ua->env_proxy; |
14 | 19 | $ua->ssl_opts(SSL_verify_mode => 0x00); |
15 | 20 | |
16 | - my $result_v4 = $ua->get("http://copr.fedoraproject.org/api/coprs/softwarepublico/v4/monitor/"); | |
17 | - my $result_v5 = $ua->get("http://copr.fedoraproject.org/api/coprs/softwarepublico/v5/monitor/"); | |
21 | + my $result_v4 = $ua->get(copr_monitor_url("softwarepublico", "v4")); | |
22 | + my $result_v5 = $ua->get(copr_monitor_url("softwarepublico", "v5")); | |
18 | 23 | |
19 | 24 | my $json = JSON->new->allow_nonref; |
20 | 25 | ... | ... |
t/app.t
... | ... | @@ -2,7 +2,7 @@ use strict; |
2 | 2 | use warnings; |
3 | 3 | use Test::More; |
4 | 4 | |
5 | -BEGIN { use_ok('CoprStatus') } | |
5 | +BEGIN { use_ok('CoprStatus'); } | |
6 | 6 | |
7 | 7 | my $info = CoprStatus::copr_info(); |
8 | 8 | ok(ref($info), 'HASH'); |
... | ... | @@ -27,4 +27,8 @@ like($table, qr/danger|success/m); |
27 | 27 | my $html = CoprStatus::build_html(); |
28 | 28 | like($html, qr/SPB Copr Status/m); |
29 | 29 | |
30 | +my $monitor_url = copr_monitor_url("foo", "bar"); | |
31 | +my $test_url = "http://copr.fedoraproject.org/api/coprs/foo/bar/monitor/"; | |
32 | +is($monitor_url, $test_url); | |
33 | + | |
30 | 34 | done_testing(); | ... | ... |