@@ -5,6 +5,13 @@ import std.stdio;
55
66string [] repositories = [" dlang/phobos" ];
77
8+ void dontTestStalled (ref Json j)
9+ {
10+ import std.datetime : Clock , days;
11+ j[$ - 1 ][" created_at" ] = (Clock .currTime - 2. days).toISOExtString;
12+ j[$ - 1 ][" updated_at" ] = (Clock .currTime - 2. days).toISOExtString;
13+ }
14+
815// test the first items of the cron job
916unittest
1017{
@@ -62,13 +69,13 @@ unittest
6269// test that stalled isn't falsely removed (e.g. by recent labelling)
6370unittest
6471{
65- import std.datetime : Clock , days;
6672 setAPIExpectations(
6773 " /github/repos/dlang/phobos/issues?state=open&sort=updated&direction=asc" , (ref Json j) {
6874 // only test one pull request
6975 j = Json([j[0 ]]);
7076 },
7177 " /github/repos/dlang/phobos/pulls/2526" , (ref Json j) {
78+ import std.datetime : Clock , days;
7279 // simulate a recent label update
7380 j[" updated_at" ] = (Clock .currTime - 2. days).toISOExtString;
7481 },
@@ -88,7 +95,6 @@ unittest
8895// test that no label updates are sent if no activity was found
8996unittest
9097{
91- import std.datetime : Clock , days;
9298 setAPIExpectations(
9399 " /github/repos/dlang/phobos/issues?state=open&sort=updated&direction=asc" , (ref Json j) {
94100 // only test one pull request
@@ -98,10 +104,7 @@ unittest
98104 j[" mergeable" ] = false ;
99105 },
100106 " /github/repos/dlang/phobos/status/a04acd6a2813fb344d3e47369cf7fd64523ece44" ,
101- " /github/repos/dlang/phobos/issues/2526/comments" , (ref Json j) {
102- j[$ - 1 ][" created_at" ] = (Clock .currTime - 2. days).toISOExtString;
103- j[$ - 1 ][" updated_at" ] = (Clock .currTime - 2. days).toISOExtString;
104- },
107+ " /github/repos/dlang/phobos/issues/2526/comments" , &dontTestStalled,
105108 " /github/repos/dlang/phobos/pulls/2526/comments" ,
106109 );
107110
@@ -111,7 +114,6 @@ unittest
111114// test that the merge state gets refreshed
112115unittest
113116{
114- import std.datetime : Clock , days;
115117 setAPIExpectations(
116118 " /github/repos/dlang/phobos/issues?state=open&sort=updated&direction=asc" , (ref Json j) {
117119 // only test one pull request
@@ -125,10 +127,7 @@ unittest
125127 j[" mergeable_state" ] = " dirty" ;
126128 },
127129 " /github/repos/dlang/phobos/status/a04acd6a2813fb344d3e47369cf7fd64523ece44" ,
128- " /github/repos/dlang/phobos/issues/2526/comments" , (ref Json j) {
129- j[$ - 1 ][" created_at" ] = (Clock .currTime - 2. days).toISOExtString;
130- j[$ - 1 ][" updated_at" ] = (Clock .currTime - 2. days).toISOExtString;
131- },
130+ " /github/repos/dlang/phobos/issues/2526/comments" , &dontTestStalled,
132131 " /github/repos/dlang/phobos/pulls/2526/comments" ,
133132 " /github/repos/dlang/phobos/issues/2526/labels" ,
134133 (scope HTTPServerRequest req, scope HTTPServerResponse res){
@@ -139,3 +138,30 @@ unittest
139138
140139 testCronDaily(repositories);
141140}
141+
142+ // for "blocked" PRs, the `mergeable` attribute should be preferred
143+ // if mergeable is true, "needs rebase" should be removed
144+ unittest
145+ {
146+ setAPIExpectations(
147+ " /github/repos/dlang/phobos/issues?state=open&sort=updated&direction=asc" , (ref Json j) {
148+ // only test one pull request
149+ j = Json([j[0 ]]);
150+ j[0 ][" labels" ][0 ][" name" ] = " needs rebase" ;
151+ },
152+ " /github/repos/dlang/phobos/pulls/2526" , (ref Json j) {
153+ j[" mergeable" ] = true ;
154+ j[" mergeable_state" ] = " blocked" ;
155+ },
156+ " /github/repos/dlang/phobos/status/a04acd6a2813fb344d3e47369cf7fd64523ece44" ,
157+ " /github/repos/dlang/phobos/issues/2526/comments" , &dontTestStalled,
158+ " /github/repos/dlang/phobos/pulls/2526/comments" ,
159+ " /github/repos/dlang/phobos/issues/2526/labels" ,
160+ (scope HTTPServerRequest req, scope HTTPServerResponse res){
161+ assert (req.method == HTTPMethod.PUT );
162+ assert (req.json[].length == 0 );
163+ },
164+ );
165+
166+ testCronDaily(repositories);
167+ }
0 commit comments