Skip to content

Commit 2022c29

Browse files
committed
Add base_url attribute
1 parent 2fa0e5e commit 2022c29

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

lib/OpenQA/Schema/Result/ScheduledProducts.pm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,9 +939,8 @@ sub report_status_to_git ($self, $callback = undef) {
939939
$vcs->read_settings($settings) or return undef;
940940
my ($state, $verb, $count, $total) = $self->state_for_ci_status;
941941
return undef unless $state;
942-
my $base_url = $settings->{CI_TARGET_URL};
943942
my %params = (state => $state, description => _format_check_description($verb, $count, $total));
944-
$vcs->report_status_to_git(\%params, $id, $base_url, $callback);
943+
$vcs->report_status_to_git(\%params, $id, $callback);
945944
}
946945

947946
sub cancel ($self, $reason = undef) {

lib/OpenQA/VcsProvider.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@ use Mojo::JSON qw(encode_json);
88
use Mojo::URL;
99

1010
has 'app';
11+
has 'base_url';
1112
has 'statuses_url';
1213

1314
sub read_settings ($self, $settings) {
1415
$self->statuses_url($settings->{GITHUB_STATUSES_URL});
16+
$self->base_url($settings->{CI_TARGET_URL});
1517
return undef unless $self->statuses_url;
1618
return 1;
1719
}
1820

19-
sub report_status_to_git ($self, $params, $scheduled_product_id, $base_url, $callback = undef) {
21+
sub report_status_to_git ($self, $params, $scheduled_product_id, $callback = undef) {
2022
$params->{context} //= 'openqa';
2123
$params->{description} //= 'openQA test run';
24+
my $base_url = $self->base_url;
2225
$params->{target_url} //= "$base_url/admin/productlog?id=$scheduled_product_id"
2326
if $scheduled_product_id && $base_url;
2427

lib/OpenQA/WebAPI/Controller/API/V1/Webhook.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ sub product ($self) {
154154
};
155155
$scheduled_product->discard_changes; # load value of columns that have a default value
156156
$vcs->statuses_url($statuses_url);
157-
# $vcs->read_settings($settings) or return undef;
158-
my $tx = $vcs->report_status_to_git({state => 'pending'}, $scheduled_product->id, $base_url, $cb);
157+
$vcs->base_url($base_url);
158+
my $tx = $vcs->report_status_to_git({state => 'pending'}, $scheduled_product->id, $cb);
159159
}
160160

161161
1;

t/16-utils-vcs-provider.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ subtest 'reporting status to GitHub' => sub {
2222

2323
my $git = OpenQA::VcsProvider->new(app => $app);
2424
my $url = 'http://127.0.0.1/repos/some/repo/statuses/some-sha';
25-
$git->read_settings({GITHUB_STATUSES_URL => $url});
26-
my $tx = $git->report_status_to_git({state => 'pending'}, '42', 'https://openqa.opensuse.org');
25+
$git->read_settings({GITHUB_STATUSES_URL => $url, CI_TARGET_URL => 'https://openqa.opensuse.org'});
26+
my $tx = $git->report_status_to_git({state => 'pending'}, '42');
2727
my $req = $tx->req;
2828
is $req->method, 'POST', 'method';
2929
is $req->url, $url, 'URL';

t/api/16-webhooks.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ my $expected_ci_check_state = 'pending';
101101
my $expected_ci_check_desc = undef;
102102
$vcs_mock->redefine(
103103
report_status_to_git =>
104-
sub ($self, $params, $scheduled_product_id, $base_url_from_req, $callback) {
104+
sub ($self, $params, $scheduled_product_id, $callback) {
105105
my $tx = $ua->build_tx(POST => 'http://dummy');
106106
is $self->statuses_url, $expected_statuses_url, 'URL from webhook payload used for reporting back';
107107
is $params->{state}, $expected_ci_check_state, "check reported to be $expected_ci_check_state";

0 commit comments

Comments
 (0)