From c1836497af19e809ffb60017b28416a68467fa10 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Thu, 9 Feb 2017 22:01:57 +0100 Subject: Implement relevant functionality for bot, pagination! --- bot/test/PRServiceTests.scala | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'bot/test') 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() + } } -- cgit v1.2.3