11#! /usr/bin/env bash
22
33source test/init
4- plan tests 11
4+ plan tests 13
55
66mock_osc () {
77 local cmd=$1
88 local args=(${@: 2} )
9- if [[ $cmd == ' request' && ${args[0]} == ' list' ]]; then
9+ if [[ $cmd == ' request' && ${args[0]} == ' list' && ${args[9]} == ' --days ' && ${args[10]} == " $throttle_days " ]]; then
1010 _request_list
1111 fi
1212}
1313
14- _request_list () {
15- echo " Created by: foo"
16- }
14+ _requests=(
15+ ' submit: devel:openQA:tested/openQA@c0f8ee6a233ed250dbc54c19dee50118 -> openSUSE:Factory'
16+ ' maintenance_incident: devel:openQA:tested/openQA@ae3d930a703dc411e249d644ad8b6802 -> openSUSE:Maintenance (release in openSUSE:Backports:SLE-15-SP6:Update)'
17+ )
18+
19+ _request_list () { echo " ${_requests[@]} " ; }
1720
1821mock_git_obs () {
1922 if [[ $3 == ' repos/pool/openQA/pulls?state=open&sort=recentupdate' ]]; then
@@ -42,12 +45,10 @@ is "$rc" 0 "returns 0 with throttle_days=0"
4245
4346throttle_days=1
4447try has_pending_submission " $package " " $submit_target "
45- is " $rc " 1 " returns 1 with existing SRs "
46- like " $got " " Created by: foo " " expected output"
48+ is " $rc " 1 " returns 1 with existing SR "
49+ like " $got " " Skipping submission, there is still a pending SR for package os-autoinst " " expected output"
4750
48- _request_list () {
49- echo " "
50- }
51+ _request_list () { echo ; }
5152try has_pending_submission " $package " " $submit_target "
5253is " $rc " 0 " returns 0 without existing SRs"
5354like " $got " " info.*has_pending_submission" " no output"
@@ -66,5 +67,11 @@ like "$got" "info.*has_pending_submission\\($package, $submit_target\\)$" "no ou
6667
6768throttle_days_leap_16=3
6869try has_pending_submission " $package " " $submit_target "
69- is " $rc " 1 " returns 1 with existing PR recent than throttle config of $throttle_days days"
70+ is " $rc " 1 " returns 1 with existing PR that is more recent than throttle config of $throttle_days days"
7071like " $got " " info.*Skipping submission.*pending PR.*https://foo/bar" " expected output (recent PR)"
72+
73+ _request_list () { echo " ${_requests[@]} " ; }
74+ submit_target=openSUSE:Backports:SLE-15-SP6:Update
75+ try has_pending_submission " $package " " $submit_target "
76+ is " $rc " 1 " returns 1 with existing maintenance incident that is more recent than throttle config of $throttle_days days"
77+ like " $got " " info.*Skipping submission.*pending SR"
0 commit comments