Skip to content

Commit fb7702a

Browse files
committed
Move avoid checking for stallement into a separate function
1 parent 378757c commit fb7702a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

test/cronjob.d

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import std.stdio;
55

66
string[] 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
916
unittest
1017
{
@@ -62,13 +69,13 @@ unittest
6269
// test that stalled isn't falsely removed (e.g. by recent labelling)
6370
unittest
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
8996
unittest
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
112115
unittest
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){

0 commit comments

Comments
 (0)