Skip to content

Commit 134f089

Browse files
committedMay 26, 2015
[WIP] #3 - Refactored tests and minor changes to code
1 parent 064b149 commit 134f089

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed
 

‎src/main/scala/codecheck/github/models/Issue.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ case class IssueListOption4Repository(
9191
direction: SortDirection = SortDirection.desc,
9292
since: Option[DateTime] = None
9393
) {
94-
def q: String = "?" + (if (!milestone.isEmpty) (milestone map (t => s"milestone=$t&")).get else "") +
94+
def q = "?" + (if (!milestone.isEmpty) (milestone map (t => s"milestone=$t&")).get else "") +
9595
s"state=$state" +
9696
(if (!assignee.isEmpty) (assignee map (t => s"&assignee=$t")).get else "") +
9797
(if (!creator.isEmpty) (creator map (t => s"&creator=$t")).get else "") +

‎src/main/scala/codecheck/github/operations/IssueOp.scala

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ trait IssueOp {
2626
)
2727
}
2828

29+
//Only listAll/User/OrgIssues return Repository object
2930
def listAllIssues(option: IssueListOption = IssueListOption()): Future[List[Issue]] =
3031
doList("/issues" + option.q)
3132

‎src/test/scala/IssueOpSpec.scala

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
import org.scalatest.FunSpec
3+
import org.scalatest.BeforeAndAfter
34
import scala.concurrent.Await
45
import org.joda.time.DateTime
56
import org.joda.time.DateTimeZone
@@ -12,6 +13,8 @@ import codecheck.github.models.Issue
1213
import codecheck.github.models.IssueInput
1314
import codecheck.github.models.MilestoneSearchOption
1415

16+
import codecheck.github.models.MilestoneInput
17+
1518
class IssueOpSpec extends FunSpec with Constants {
1619

1720
val number = 1
@@ -108,6 +111,7 @@ class IssueOpSpec extends FunSpec with Constants {
108111
it("shold return at least one issue.") {
109112
val result = Await.result(api.listAllIssues(), TIMEOUT)
110113
assert(result.length > 0)
114+
assert(result.head.repository.name == "test-repo")
111115
}
112116

113117
it("shold return only two issues when using options.") {
@@ -122,6 +126,7 @@ class IssueOpSpec extends FunSpec with Constants {
122126
it("shold return at least one issue.") {
123127
val result = Await.result(api.listUserIssues(), TIMEOUT)
124128
assert(result.length > 0)
129+
assert(result.head.repository.name == "test-repo")
125130
}
126131

127132
it("shold return only one issues when using options.") {
@@ -148,7 +153,7 @@ class IssueOpSpec extends FunSpec with Constants {
148153

149154
describe("listRepositoryIssues(owner, repo, option)") {
150155
it("should return at least one issue from user's own repo.") {
151-
val result = Await.result(api.listRepositoryIssues(organization, repo), TIMEOUT)
156+
val result = Await.result(api.listRepositoryIssues(user, userRepo), TIMEOUT)
152157
assert(result.length > 0)
153158
}
154159

@@ -159,17 +164,17 @@ class IssueOpSpec extends FunSpec with Constants {
159164

160165
it("should return only one issue from user's own repo when using options.") {
161166
val option = new IssueListOption4Repository(Some(MilestoneSearchOption(1)), IssueState.open, Some(user), Some(user), labels=Seq("question"), since=Some(nTime))
162-
val result = Await.result(api.listRepositoryIssues(user, userRepo), TIMEOUT)
163-
//showResponse(result)
167+
val result = Await.result(api.listRepositoryIssues(user, userRepo, option), TIMEOUT)
168+
showResponse(option.q)
164169
assert(result.length == 1)
170+
assert(result.head.title == "test issue")
165171
}
166172

167173
it("should return only one issue from organization's repo when using options.") {
168-
val option = IssueListOption4Repository(Some(MilestoneSearchOption.all), IssueState.open, Some(user), Some(user), labels=Seq("question"), since=Some(nTime))
174+
val option = new IssueListOption4Repository(Some(MilestoneSearchOption(1)), IssueState.open, Some(user), Some(user), labels=Seq("question"), since=Some(nTime))
169175
val result = Await.result(api.listRepositoryIssues(organization, repo, option), TIMEOUT)
170-
showResponse(option.q)
171-
showResponse(result)
172-
//assert(result.length == 1)
176+
assert(result.length == 1)
177+
assert(result.head.title == "test issue")
173178
}
174179
}
175180

0 commit comments

Comments
 (0)