@@ -10,21 +10,20 @@ import codecheck.github.models.IssueListOption4Repository
10
10
import codecheck .github .models .IssueState
11
11
import codecheck .github .models .Issue
12
12
import codecheck .github .models .IssueInput
13
+ import codecheck .github .models .MilestoneSearchOption
13
14
14
15
class IssueOpSpec extends FunSpec with Constants {
15
16
16
17
val number = 1
17
18
var nUser : Long = 0
18
19
var nOrg : Long = 0
19
- var createdUser : DateTime = DateTime .now
20
- var createdOrg : DateTime = DateTime .now
20
+ var nTime : DateTime = DateTime .now()
21
21
22
22
describe(" createIssue(owner, repo, input)" ) {
23
23
val input = IssueInput (Some (" test issue" ), Some (" testing" ), Some (user), Some (1 ), Seq (" question" ))
24
24
25
25
it(" should create issue for user's own repo." ) {
26
26
val result = Await .result(api.createIssue(user, userRepo, input), TIMEOUT )
27
- // showResponse(result)
28
27
nUser = result.number
29
28
assert(result.url == " https://api.github.com/repos/" + user + " /" + userRepo + " /issues/" + nUser)
30
29
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 {
41
40
assert(result.comments == 0 )
42
41
assert(result.created_at.toDateTime(DateTimeZone .UTC ).getMillis() - DateTime .now(DateTimeZone .UTC ).getMillis() <= 5000 )
43
42
assert(result.updated_at.toDateTime(DateTimeZone .UTC ).getMillis() - DateTime .now(DateTimeZone .UTC ).getMillis() <= 5000 )
44
- createdUser = result.created_at
45
43
assert(result.closed_at.isEmpty)
46
44
assert(result.body.get == " testing" )
47
45
assert(result.closed_by.isEmpty)
@@ -65,8 +63,6 @@ class IssueOpSpec extends FunSpec with Constants {
65
63
assert(result.comments == 0 )
66
64
assert(result.created_at.toDateTime(DateTimeZone .UTC ).getMillis() - DateTime .now(DateTimeZone .UTC ).getMillis() <= 5000 )
67
65
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)
70
66
assert(result.body.get == " testing" )
71
67
assert(result.closed_by.isEmpty)
72
68
}
@@ -114,10 +110,10 @@ class IssueOpSpec extends FunSpec with Constants {
114
110
assert(result.length > 0 )
115
111
}
116
112
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 ))
119
115
val result = Await .result(api.listAllIssues(option), TIMEOUT )
120
- assert(result.length == 1 )
116
+ assert(result.length == 2 )
121
117
assert(result.head.title == " test issue" )
122
118
}
123
119
}
@@ -127,26 +123,53 @@ class IssueOpSpec extends FunSpec with Constants {
127
123
val result = Await .result(api.listUserIssues(), TIMEOUT )
128
124
assert(result.length > 0 )
129
125
}
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
+ }
130
133
}
131
134
132
135
describe(" listOrgIssues(org, option)" ) {
133
136
it(" should return at least one issue." ) {
134
137
val result = Await .result(api.listOrgIssues(organization), TIMEOUT )
135
138
assert(result.length > 0 )
136
139
}
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
+ }
137
147
}
138
148
139
149
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 ." ) {
141
151
val result = Await .result(api.listRepositoryIssues(organization, repo), TIMEOUT )
142
152
assert(result.length > 0 )
143
153
}
144
- }
145
154
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)
150
173
}
151
174
}
152
175
0 commit comments