1-
21import org .scalatest .FunSpec
3- import org .scalatest .BeforeAndAfter
2+ import org .scalatest .BeforeAndAfterAll
43import scala .concurrent .Await
54import org .joda .time .DateTime
65import org .joda .time .DateTimeZone
@@ -18,36 +17,33 @@ import codecheck.github.models.MilestoneListOption
1817import codecheck .github .models .MilestoneState
1918import codecheck .github .models .Milestone
2019
21- class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
20+ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfterAll {
2221
2322 val number = 1
2423 var nUser : Long = 0
2524 var nOrg : Long = 0
2625 var nTime : DateTime = DateTime .now()
26+ val tRepo = repo + " 2"
2727
28- private def removeAll = {
28+ override def beforeAll () {
2929 val userMilestones = Await .result(api.listMilestones(user, userRepo, MilestoneListOption (state= MilestoneState .all)), TIMEOUT )
3030 userMilestones.foreach { m =>
3131 Await .result(api.removeMilestone(user, userRepo, m.number), TIMEOUT )
3232 }
3333
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 )
3535 orgMilestones.foreach { m =>
36- Await .result(api.removeMilestone(organization, repo , m.number), TIMEOUT )
36+ Await .result(api.removeMilestone(organization, tRepo , m.number), TIMEOUT )
3737 }
38- }
39-
40- before {
41- removeAll
4238
4339 val nInput = new MilestoneInput (Some (" test milestone" ))
4440 val nInput2 = new MilestoneInput (Some (" test milestone 2" ))
4541
4642 Await .result(api.createMilestone(user, userRepo, nInput), TIMEOUT )
47- Await .result(api.createMilestone(organization, repo, nInput), TIMEOUT )
48-
4943 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 )
5147 }
5248
5349 describe(" createIssue(owner, repo, input)" ) {
@@ -77,13 +73,13 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
7773 }
7874
7975 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 )
8177 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)
8783 assert(result.title == " test issue" )
8884 assert(result.user.login == user)
8985 assert(result.labels.head.name == " question" )
@@ -106,7 +102,7 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
106102 }
107103
108104 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 )
110106 assert(result.get.title == " test issue" )
111107 }
112108 }
@@ -118,7 +114,7 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
118114 }
119115
120116 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 )
122118 assert(result.opt(" assignee" ).isEmpty)
123119 }
124120 }
@@ -130,7 +126,7 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
130126 }
131127
132128 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 )
134130 assert(result.get(" assignee.login" ) == user)
135131 }
136132 }
@@ -139,7 +135,6 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
139135 it(" shold return at least one issue." ) {
140136 val result = Await .result(api.listAllIssues(), TIMEOUT )
141137 assert(result.length > 0 )
142- assert(result.head.repository.name == " test-repo" )
143138 }
144139
145140 it(" shold return only two issues when using options." ) {
@@ -154,7 +149,6 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
154149 it(" shold return at least one issue." ) {
155150 val result = Await .result(api.listUserIssues(), TIMEOUT )
156151 assert(result.length > 0 )
157- assert(result.head.repository.name == " test-repo" )
158152 }
159153
160154 it(" shold return only one issues when using options." ) {
@@ -186,21 +180,21 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
186180 }
187181
188182 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 )
190184 assert(result.length > 0 )
191185 }
192186
193187 it(" should return only one issue from user's own repo when using options." ) {
194188 val option = new IssueListOption4Repository (Some (MilestoneSearchOption (1 )), IssueState .open, Some (user), Some (user), labels= Seq (" question" ), since= Some (nTime))
195189 val result = Await .result(api.listRepositoryIssues(user, userRepo, option), TIMEOUT )
196- showResponse(option.q)
190+ // showResponse(option.q)
197191 assert(result.length == 1 )
198192 assert(result.head.title == " test issue" )
199193 }
200194
201195 it(" should return only one issue from organization's repo when using options." ) {
202196 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 )
204198 assert(result.length == 1 )
205199 assert(result.head.title == " test issue" )
206200 }
@@ -220,7 +214,7 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfter {
220214 }
221215
222216 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 )
224218 assert(result.title == " test issue edited" )
225219 assert(result.body.get == " testing again" )
226220 assert(result.milestone.get.number == 2 )
0 commit comments