@@ -10,21 +10,20 @@ import codecheck.github.models.IssueListOption4Repository
1010import codecheck .github .models .IssueState
1111import codecheck .github .models .Issue
1212import codecheck .github .models .IssueInput
13+ import codecheck .github .models .MilestoneSearchOption
1314
1415class IssueOpSpec extends FunSpec with Constants {
1516
1617 val number = 1
1718 var nUser : Long = 0
1819 var nOrg : Long = 0
19- var createdUser : DateTime = DateTime .now
20- var createdOrg : DateTime = DateTime .now
20+ var nTime : DateTime = DateTime .now()
2121
2222 describe(" createIssue(owner, repo, input)" ) {
2323 val input = IssueInput (Some (" test issue" ), Some (" testing" ), Some (user), Some (1 ), Seq (" question" ))
2424
2525 it(" should create issue for user's own repo." ) {
2626 val result = Await .result(api.createIssue(user, userRepo, input), TIMEOUT )
27- // showResponse(result)
2827 nUser = result.number
2928 assert(result.url == " https://api.github.com/repos/" + user + " /" + userRepo + " /issues/" + nUser)
3029 assert(result.labels_url == " https://api.github.com/repos/" + user + " /" + userRepo + " /issues/" + nUser + " /labels{/name}" )
@@ -41,7 +40,6 @@ class IssueOpSpec extends FunSpec with Constants {
4140 assert(result.comments == 0 )
4241 assert(result.created_at.toDateTime(DateTimeZone .UTC ).getMillis() - DateTime .now(DateTimeZone .UTC ).getMillis() <= 5000 )
4342 assert(result.updated_at.toDateTime(DateTimeZone .UTC ).getMillis() - DateTime .now(DateTimeZone .UTC ).getMillis() <= 5000 )
44- createdUser = result.created_at
4543 assert(result.closed_at.isEmpty)
4644 assert(result.body.get == " testing" )
4745 assert(result.closed_by.isEmpty)
@@ -65,8 +63,6 @@ class IssueOpSpec extends FunSpec with Constants {
6563 assert(result.comments == 0 )
6664 assert(result.created_at.toDateTime(DateTimeZone .UTC ).getMillis() - DateTime .now(DateTimeZone .UTC ).getMillis() <= 5000 )
6765 assert(result.updated_at.toDateTime(DateTimeZone .UTC ).getMillis() - DateTime .now(DateTimeZone .UTC ).getMillis() <= 5000 )
68- createdOrg = result.created_at
69- assert(result.closed_at.isEmpty)
7066 assert(result.body.get == " testing" )
7167 assert(result.closed_by.isEmpty)
7268 }
@@ -114,10 +110,10 @@ class IssueOpSpec extends FunSpec with Constants {
114110 assert(result.length > 0 )
115111 }
116112
117- it(" shold return only one issue ." ) {
118- val option = IssueListOption (IssueFilter .all , IssueState .open, since= Some (createdUser ))
113+ it(" shold return only two issues when using options ." ) {
114+ val option = IssueListOption (IssueFilter .created , IssueState .open, Seq ( " question " ), since= Some (nTime ))
119115 val result = Await .result(api.listAllIssues(option), TIMEOUT )
120- assert(result.length == 1 )
116+ assert(result.length == 2 )
121117 assert(result.head.title == " test issue" )
122118 }
123119 }
@@ -127,26 +123,53 @@ class IssueOpSpec extends FunSpec with Constants {
127123 val result = Await .result(api.listUserIssues(), TIMEOUT )
128124 assert(result.length > 0 )
129125 }
126+
127+ it(" shold return only one issues when using options." ) {
128+ val option = IssueListOption (IssueFilter .created, IssueState .open, Seq (" question" ), since= Some (nTime))
129+ val result = Await .result(api.listUserIssues(option), TIMEOUT )
130+ assert(result.length == 1 )
131+ assert(result.head.title == " test issue" )
132+ }
130133 }
131134
132135 describe(" listOrgIssues(org, option)" ) {
133136 it(" should return at least one issue." ) {
134137 val result = Await .result(api.listOrgIssues(organization), TIMEOUT )
135138 assert(result.length > 0 )
136139 }
140+
141+ it(" shold return only one issues when using options." ) {
142+ val option = IssueListOption (IssueFilter .created, IssueState .open, Seq (" question" ), since= Some (nTime))
143+ val result = Await .result(api.listOrgIssues(organization, option), TIMEOUT )
144+ assert(result.length == 1 )
145+ assert(result.head.title == " test issue" )
146+ }
137147 }
138148
139149 describe(" listRepositoryIssues(owner, repo, option)" ) {
140- it(" should return at least one issue." ) {
150+ it(" should return at least one issue from user's own repo ." ) {
141151 val result = Await .result(api.listRepositoryIssues(organization, repo), TIMEOUT )
142152 assert(result.length > 0 )
143153 }
144- }
145154
146- describe(" listRepositoryIssues" ) {
147- it(" is just testing." ) {
148- val input = new IssueListOption4Repository (state= IssueState .all)
149- val result = Await .result(api.listRepositoryIssues(organization, repo, input), TIMEOUT )
155+ it(" should return at least one issue from organization's repo." ) {
156+ val result = Await .result(api.listRepositoryIssues(organization, repo), TIMEOUT )
157+ assert(result.length > 0 )
158+ }
159+
160+ it(" should return only one issue from user's own repo when using options." ) {
161+ 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)
164+ assert(result.length == 1 )
165+ }
166+
167+ 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))
169+ val result = Await .result(api.listRepositoryIssues(organization, repo, option), TIMEOUT )
170+ showResponse(option.q)
171+ showResponse(result)
172+ // assert(result.length == 1)
150173 }
151174 }
152175
0 commit comments