44
55use Test::Most;
66
7+ use Mojo::Base -signatures;
78use FindBin;
89use lib " $FindBin::Bin /lib" , " $FindBin::Bin /../external/os-autoinst-common/lib" ;
910require OpenQA::Test::Database;
1011use OpenQA::Test::TimeLimit ' 5' ;
11- use OpenQA::VcsProvider;
12+ use OpenQA::VcsProvider::GitHub;
13+ use OpenQA::VcsProvider::Gitea;
1214use Test::Mojo;
1315use Test::Warnings ' :report_warnings' ;
1416
1517my $schema = OpenQA::Test::Database-> new-> create(fixtures_glob => ' 03-users.pl' );
1618my $t = Test::Mojo-> new(' OpenQA::WebAPI' );
1719
18- subtest ' reporting status to GitHub ' => sub {
20+ sub test_report_status_to_git ( $app , $statuses_url_key , $webhook_id ) {
1921 # avoid making an actual query to GitHub; this test just checks whether an expected request would have been done
20- my $app = $t -> app;
21- $app -> config-> {secrets }-> {github_token } = ' some-token' ;
2222
23- my $git = OpenQA::VcsProvider-> new(app => $app );
23+ my $git = OpenQA::VcsProvider-> new(app => $app , type => $webhook_id );
2424 my $url = ' http://127.0.0.1/repos/some/repo/statuses/some-sha' ;
25- $git -> read_settings({GITHUB_STATUSES_URL => $url , CI_TARGET_URL => ' https://openqa.opensuse.org' });
25+ $git -> read_settings({$statuses_url_key => $url , CI_TARGET_URL => ' https://openqa.opensuse.org' });
2626 my $tx = $git -> report_status_to_git({state => ' pending' }, ' 42' );
2727 my $req = $tx -> req;
2828 is $req -> method, ' POST' , ' method' ;
@@ -38,4 +38,17 @@ subtest 'reporting status to GitHub' => sub {
3838 ok $tx -> is_finished, ' transaction has finished (and thus was started in first place)' ;
3939};
4040
41+
42+ subtest ' reporting status to GitHub' => sub {
43+ my $app = $t -> app;
44+ $app -> config-> {secrets }-> {github_token } = ' some-token' ;
45+ test_report_status_to_git($app , ' GITHUB_STATUSES_URL' , ' gh:pr:123' );
46+ };
47+
48+ subtest ' reporting status to Gitea' => sub {
49+ my $app = $t -> app;
50+ $app -> config-> {secrets }-> {gitea_token } = ' some-token' ;
51+ test_report_status_to_git($app , ' GITEA_STATUSES_URL' , ' gitea:pr:123' );
52+ };
53+
4154done_testing();
0 commit comments