Skip to content

Commit 4263907

Browse files
committed
Use withClient helper in all tests
1 parent 6a633ef commit 4263907

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

bot/test/PRServiceTests.scala

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ class PRServiceTests extends PullRequestService {
4040
}
4141

4242
@Test def canGetAllCommitsFromPR = {
43-
val httpClient = PooledHttp1Client()
4443
val issueNbr = 1941 // has 2 commits: https://github.com/lampepfl/dotty/pull/1941/commits
45-
46-
val List(c1, c2) = getCommits(issueNbr, httpClient).run
44+
val List(c1, c2) = withClient(getCommits(issueNbr, _))
4745

4846
assertEquals(
4947
"Represent untyped operators as Ident instead of Name",
@@ -57,10 +55,8 @@ class PRServiceTests extends PullRequestService {
5755
}
5856

5957
@Test def canGetMoreThan100Commits = {
60-
val httpClient = PooledHttp1Client()
6158
val issueNbr = 1840 // has >100 commits: https://github.com/lampepfl/dotty/pull/1840/commits
62-
63-
val numberOfCommits = getCommits(issueNbr, httpClient).run.length
59+
val numberOfCommits = withClient(getCommits(issueNbr, _)).length
6460

6561
assert(
6662
numberOfCommits > 100,
@@ -69,27 +65,24 @@ class PRServiceTests extends PullRequestService {
6965
}
7066

7167
@Test def canGetComments = {
72-
val comments: List[Comment] = withClient(c => getComments(2136, c))
68+
val comments: List[Comment] = withClient(getComments(2136, _))
7369

7470
assert(comments.find(_.user.login == Some("odersky")).isDefined,
7571
"Could not find Martin's comment on PR 2136")
7672
}
7773

7874
@Test def canCheckCLA = {
79-
val httpClient = PooledHttp1Client()
8075
val validUserCommit = Commit("sha-here", Author(Some("felixmulder")), Author(Some("felixmulder")), CommitInfo(""))
81-
val statuses: List[CommitStatus] = checkCLA(validUserCommit :: Nil, httpClient).run
76+
val statuses: List[CommitStatus] = withClient(checkCLA(validUserCommit :: Nil, _))
8277

8378
assert(statuses.length == 1, s"wrong number of valid statuses: got ${statuses.length}, expected 1")
84-
httpClient.shutdownNow()
8579
}
8680

8781
@Test def canSetStatus = {
88-
val httpClient = PooledHttp1Client()
8982
val sha = "fa64b4b613fe5e78a5b4185b4aeda89e2f1446ff"
9083
val status = Invalid("smarter", Commit(sha, Author(Some("smarter")), Author(Some("smarter")), CommitInfo("")))
9184

92-
val statuses: List[StatusResponse] = sendStatuses(status :: Nil, httpClient).run
85+
val statuses: List[StatusResponse] = withClient(sendStatuses(status :: Nil, _))
9386

9487
assert(
9588
statuses.length == 1,
@@ -100,8 +93,6 @@ class PRServiceTests extends PullRequestService {
10093
statuses.head.state == "failure",
10194
s"status set had wrong state, expected 'failure', got: ${statuses.head.state}"
10295
)
103-
104-
httpClient.shutdownNow()
10596
}
10697

10798
@Test def canGetStatus = {

0 commit comments

Comments
 (0)