aboutsummaryrefslogtreecommitdiff
path: root/bot/test
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-02-09 22:01:57 +0100
committerFelix Mulder <felix.mulder@gmail.com>2017-02-13 10:53:46 +0100
commitc1836497af19e809ffb60017b28416a68467fa10 (patch)
tree371791af8cdac7370dd67dc69d888e54adeae102 /bot/test
parent43f1d800b92241d86703b5518aab171e039fde4e (diff)
downloaddotty-c1836497af19e809ffb60017b28416a68467fa10.tar.gz
dotty-c1836497af19e809ffb60017b28416a68467fa10.tar.bz2
dotty-c1836497af19e809ffb60017b28416a68467fa10.zip
Implement relevant functionality for bot, pagination!
Diffstat (limited to 'bot/test')
-rw-r--r--bot/test/PRServiceTests.scala58
1 files changed, 58 insertions, 0 deletions
diff --git a/bot/test/PRServiceTests.scala b/bot/test/PRServiceTests.scala
index a8fdba6e2..202c721e6 100644
--- a/bot/test/PRServiceTests.scala
+++ b/bot/test/PRServiceTests.scala
@@ -31,4 +31,62 @@ class PRServiceTests extends PullRequestService {
assert(issue.pull_request.isDefined, "missing pull request")
}
+
+ @Test def canGetAllCommitsFromPR = {
+ val httpClient = PooledHttp1Client()
+ val issueNbr = 1941 // has 2 commits: https://github.com/lampepfl/dotty/pull/1941/commits
+
+ val List(c1, c2) = getCommits(issueNbr, httpClient).run
+
+ assertEquals(
+ "Represent untyped operators as Ident instead of Name",
+ c1.commit.message.takeWhile(_ != '\n')
+ )
+
+ assertEquals(
+ "Better positions for infix term operations.",
+ c2.commit.message.takeWhile(_ != '\n')
+ )
+ }
+
+ @Test def canGetMoreThan100Commits = {
+ val httpClient = PooledHttp1Client()
+ val issueNbr = 1840 // has >100 commits: https://github.com/lampepfl/dotty/pull/1840/commits
+
+ val numberOfCommits = getCommits(issueNbr, httpClient).run.length
+
+ assert(
+ numberOfCommits > 100,
+ s"PR 1840, should have a number of commits greater than 100, but was: $numberOfCommits"
+ )
+ }
+
+ @Test def canCheckCLA = {
+ val httpClient = PooledHttp1Client()
+ val validUserCommit = Commit("sha-here", Author(Some("felixmulder")), Author(Some("felixmulder")), CommitInfo(""))
+ val statuses: List[CommitStatus] = checkCLA(validUserCommit :: Nil, httpClient).run
+
+ assert(statuses.length == 1, s"wrong number of valid statuses: got ${statuses.length}, expected 1")
+ httpClient.shutdownNow()
+ }
+
+ @Test def canSetStatus = {
+ val httpClient = PooledHttp1Client()
+ val sha = "fa64b4b613fe5e78a5b4185b4aeda89e2f1446ff"
+ val status = Invalid("smarter", Commit(sha, Author(Some("smarter")), Author(Some("smarter")), CommitInfo("")))
+
+ val statuses: List[StatusResponse] = sendStatuses(status :: Nil, httpClient).run
+
+ assert(
+ statuses.length == 1,
+ s"assumed one status response would be returned, got: ${statuses.length}"
+ )
+
+ assert(
+ statuses.head.state == "failure",
+ s"status set had wrong state, expected 'failure', got: ${statuses.head.state}"
+ )
+
+ httpClient.shutdownNow()
+ }
}