1
-
2
1
import org .scalatest .FunSpec
3
- import org .scalatest .BeforeAndAfter
2
+ import org .scalatest .BeforeAndAfterAll
4
3
import scala .concurrent .Await
5
4
import org .joda .time .DateTime
6
5
import org .joda .time .DateTimeZone
@@ -18,36 +17,33 @@ import codecheck.github.models.MilestoneListOption
18
17
import codecheck .github .models .MilestoneState
19
18
import codecheck .github .models .Milestone
20
19
21
- class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
20
+ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfterAll {
22
21
23
22
val number = 1
24
23
var nUser : Long = 0
25
24
var nOrg : Long = 0
26
25
var nTime : DateTime = DateTime .now()
26
+ val tRepo = repo + " 2"
27
27
28
- private def removeAll = {
28
+ override def beforeAll () {
29
29
val userMilestones = Await .result(api.listMilestones(user, userRepo, MilestoneListOption (state= MilestoneState .all)), TIMEOUT )
30
30
userMilestones.foreach { m =>
31
31
Await .result(api.removeMilestone(user, userRepo, m.number), TIMEOUT )
32
32
}
33
33
34
- val orgMilestones = Await .result(api.listMilestones(organization, repo , MilestoneListOption (state= MilestoneState .all)), TIMEOUT )
34
+ val orgMilestones = Await .result(api.listMilestones(organization, tRepo , MilestoneListOption (state= MilestoneState .all)), TIMEOUT )
35
35
orgMilestones.foreach { m =>
36
- Await .result(api.removeMilestone(organization, repo , m.number), TIMEOUT )
36
+ Await .result(api.removeMilestone(organization, tRepo , m.number), TIMEOUT )
37
37
}
38
- }
39
-
40
- before {
41
- removeAll
42
38
43
39
val nInput = new MilestoneInput (Some (" test milestone" ))
44
40
val nInput2 = new MilestoneInput (Some (" test milestone 2" ))
45
41
46
42
Await .result(api.createMilestone(user, userRepo, nInput), TIMEOUT )
47
- Await .result(api.createMilestone(organization, repo, nInput), TIMEOUT )
48
-
49
43
Await .result(api.createMilestone(user, userRepo, nInput2), TIMEOUT )
50
- Await .result(api.createMilestone(organization, repo, nInput2), TIMEOUT )
44
+
45
+ Await .result(api.createMilestone(organization, tRepo, nInput), TIMEOUT )
46
+ Await .result(api.createMilestone(organization, tRepo, nInput2), TIMEOUT )
51
47
}
52
48
53
49
describe(" createIssue(owner, repo, input)" ) {
@@ -77,13 +73,13 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
77
73
}
78
74
79
75
it(" should create issue for organization's repo." ) {
80
- val result = Await .result(api.createIssue(organization, repo , input), TIMEOUT )
76
+ val result = Await .result(api.createIssue(organization, tRepo , input), TIMEOUT )
81
77
nOrg = result.number
82
- assert(result.url == " https://api.github.com/repos/" + organization + " /" + repo + " /issues/" + nOrg)
83
- assert(result.labels_url == " https://api.github.com/repos/" + organization + " /" + repo + " /issues/" + nOrg + " /labels{/name}" )
84
- assert(result.comments_url == " https://api.github.com/repos/" + organization + " /" + repo + " /issues/" + nOrg + " /comments" )
85
- assert(result.events_url == " https://api.github.com/repos/" + organization + " /" + repo + " /issues/" + nOrg + " /events" )
86
- assert(result.html_url == " https://github.com/" + organization + " /" + repo + " /issues/" + nOrg)
78
+ assert(result.url == " https://api.github.com/repos/" + organization + " /" + tRepo + " /issues/" + nOrg)
79
+ assert(result.labels_url == " https://api.github.com/repos/" + organization + " /" + tRepo + " /issues/" + nOrg + " /labels{/name}" )
80
+ assert(result.comments_url == " https://api.github.com/repos/" + organization + " /" + tRepo + " /issues/" + nOrg + " /comments" )
81
+ assert(result.events_url == " https://api.github.com/repos/" + organization + " /" + tRepo + " /issues/" + nOrg + " /events" )
82
+ assert(result.html_url == " https://github.com/" + organization + " /" + tRepo + " /issues/" + nOrg)
87
83
assert(result.title == " test issue" )
88
84
assert(result.user.login == user)
89
85
assert(result.labels.head.name == " question" )
@@ -106,7 +102,7 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
106
102
}
107
103
108
104
it(" should return issue from organization's repo." ) {
109
- val result = Await .result(api.getIssue(organization, repo , nOrg), TIMEOUT )
105
+ val result = Await .result(api.getIssue(organization, tRepo , nOrg), TIMEOUT )
110
106
assert(result.get.title == " test issue" )
111
107
}
112
108
}
@@ -118,7 +114,7 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
118
114
}
119
115
120
116
it(" should succeed with valid inputs on issues in organization's repo." ) {
121
- val result = Await .result(api.unassign(organization, repo , nOrg), TIMEOUT )
117
+ val result = Await .result(api.unassign(organization, tRepo , nOrg), TIMEOUT )
122
118
assert(result.opt(" assignee" ).isEmpty)
123
119
}
124
120
}
@@ -130,7 +126,7 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
130
126
}
131
127
132
128
it(" should succeed with valid inputs on issues in organization's repo." ) {
133
- val result = Await .result(api.assign(organization, repo , nOrg, user), TIMEOUT )
129
+ val result = Await .result(api.assign(organization, tRepo , nOrg, user), TIMEOUT )
134
130
assert(result.get(" assignee.login" ) == user)
135
131
}
136
132
}
@@ -139,7 +135,6 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
139
135
it(" shold return at least one issue." ) {
140
136
val result = Await .result(api.listAllIssues(), TIMEOUT )
141
137
assert(result.length > 0 )
142
- assert(result.head.repository.name == " test-repo" )
143
138
}
144
139
145
140
it(" shold return only two issues when using options." ) {
@@ -154,7 +149,6 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
154
149
it(" shold return at least one issue." ) {
155
150
val result = Await .result(api.listUserIssues(), TIMEOUT )
156
151
assert(result.length > 0 )
157
- assert(result.head.repository.name == " test-repo" )
158
152
}
159
153
160
154
it(" shold return only one issues when using options." ) {
@@ -186,21 +180,21 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
186
180
}
187
181
188
182
it(" should return at least one issue from organization's repo." ) {
189
- val result = Await .result(api.listRepositoryIssues(organization, repo ), TIMEOUT )
183
+ val result = Await .result(api.listRepositoryIssues(organization, tRepo ), TIMEOUT )
190
184
assert(result.length > 0 )
191
185
}
192
186
193
187
it(" should return only one issue from user's own repo when using options." ) {
194
188
val option = new IssueListOption4Repository (Some (MilestoneSearchOption (1 )), IssueState .open, Some (user), Some (user), labels= Seq (" question" ), since= Some (nTime))
195
189
val result = Await .result(api.listRepositoryIssues(user, userRepo, option), TIMEOUT )
196
- showResponse(option.q)
190
+ // showResponse(option.q)
197
191
assert(result.length == 1 )
198
192
assert(result.head.title == " test issue" )
199
193
}
200
194
201
195
it(" should return only one issue from organization's repo when using options." ) {
202
196
val option = new IssueListOption4Repository (Some (MilestoneSearchOption (1 )), IssueState .open, Some (user), Some (user), labels= Seq (" question" ), since= Some (nTime))
203
- val result = Await .result(api.listRepositoryIssues(organization, repo , option), TIMEOUT )
197
+ val result = Await .result(api.listRepositoryIssues(organization, tRepo , option), TIMEOUT )
204
198
assert(result.length == 1 )
205
199
assert(result.head.title == " test issue" )
206
200
}
@@ -220,7 +214,7 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
220
214
}
221
215
222
216
it(" should edit the issue in organization's repo." ) {
223
- val result = Await .result(api.editIssue(organization, repo , nOrg, input), TIMEOUT )
217
+ val result = Await .result(api.editIssue(organization, tRepo , nOrg, input), TIMEOUT )
224
218
assert(result.title == " test issue edited" )
225
219
assert(result.body.get == " testing again" )
226
220
assert(result.milestone.get.number == 2 )
0 commit comments