Skip to content

Commit bac136f

Browse files
committed
Update WebhookOpSpec
1 parent 760c790 commit bac136f

File tree

3 files changed

+20
-34
lines changed

3 files changed

+20
-34
lines changed

src/test/scala/IssueOpSpec.scala

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,8 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfterAll {
2525
var nTime: DateTime = DateTime.now
2626
val tRepo = "test-repo2"
2727

28-
override def beforeAll() {
29-
val userMilestones = Await.result(api.listMilestones(user, userRepo, MilestoneListOption(state=MilestoneState.all)), TIMEOUT)
30-
userMilestones.foreach { m =>
31-
Await.result(api.removeMilestone(user, userRepo, m.number), TIMEOUT)
32-
}
33-
34-
val nInput = new MilestoneInput(Some("test milestone"))
35-
val nInput2 = new MilestoneInput(Some("test milestone 2"))
36-
37-
Await.result(api.createMilestone(user, userRepo, nInput), TIMEOUT)
38-
Await.result(api.createMilestone(user, userRepo, nInput2), TIMEOUT)
39-
}
40-
4128
describe("createIssue(owner, repo, input)") {
42-
val input = IssueInput(Some("test issue"), Some("testing"), Some(user), Some(1), Seq("question"))
29+
val input = IssueInput(Some("test issue"), Some("testing"), Some(user), None, Seq("question"))
4330

4431
it("should create issue for user's own repo.") {
4532
val result = Await.result(api.createIssue(user, userRepo, input), TIMEOUT)
@@ -55,7 +42,6 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfterAll {
5542
assert(result.state == "open")
5643
assert(result.locked == false)
5744
assert(result.assignee.get.login == user)
58-
assert(result.milestone.get.number == 1)
5945
assert(result.comments == 0)
6046
assert(result.created_at.toDateTime(DateTimeZone.UTC).getMillis() - DateTime.now(DateTimeZone.UTC).getMillis() <= 5000)
6147
assert(result.updated_at.toDateTime(DateTimeZone.UTC).getMillis() - DateTime.now(DateTimeZone.UTC).getMillis() <= 5000)
@@ -179,13 +165,12 @@ class IssueOpSpec extends FunSpec with Constants with BeforeAndAfterAll {
179165
}
180166

181167
describe("editIssue(owner, repo, number, input)") {
182-
val input = IssueInput(Some("test issue edited"), Some("testing again"), Some(user), Some(2), Seq("question", "bug"), Some(IssueState.closed))
168+
val input = IssueInput(Some("test issue edited"), Some("testing again"), Some(user), None, Seq("question", "bug"), Some(IssueState.closed))
183169

184170
it("should edit the issue in user's own repo.") {
185171
val result = Await.result(api.editIssue(user, userRepo, nUser, input), TIMEOUT)
186172
assert(result.title == "test issue edited")
187173
assert(result.body.get == "testing again")
188-
assert(result.milestone.get.number == 2)
189174
assert(result.labels.head.name == "bug")
190175
assert(result.state == "closed")
191176
assert(result.updated_at.toDateTime(DateTimeZone.UTC).getMillis() - DateTime.now(DateTimeZone.UTC).getMillis() <= 5000)

src/test/scala/WebhookOpSpec.scala

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ class WebhookOpSpec extends FunSpec with Constants with BeforeAndAfter {
1616

1717
describe("listWebhooks(owner, repo)") {
1818
it("should succeed with valid owner, repo.") {
19-
val result = Await.result(api.listWebhooks(organization, repo), TIMEOUT)
20-
assert(result.length > 0)
19+
val result = Await.result(api.listWebhooks(user, userRepo), TIMEOUT)
20+
assert(result.length >= 0)
2121
}
2222
}
2323

2424
describe("createWebhook(owner, repo, input)") {
25-
it("should succeed with valid organization, repo, and inputs.") {
25+
it("should succeed with valid user, repo, and inputs.") {
2626
val config = WebhookConfig(targetURL)
2727
val input = WebhookCreateInput("web", config, events=Seq("*"))
28-
val res = Await.result(api.createWebhook(organization, repo, input), TIMEOUT)
28+
val res = Await.result(api.createWebhook(user, userRepo, input), TIMEOUT)
2929
showResponse(res)
3030
nID = res.id
31-
assert(res.url == "https://api.github.com/repos/" + organization + "/" + repo + "/hooks/" + nID)
32-
assert(res.test_url == "https://api.github.com/repos/" + organization + "/" + repo + "/hooks/" + nID + "/test")
33-
assert(res.ping_url == "https://api.github.com/repos/" + organization + "/" + repo + "/hooks/" + nID + "/pings")
31+
assert(res.url == "https://api.github.com/repos/" + user + "/" + userRepo + "/hooks/" + nID)
32+
assert(res.test_url == "https://api.github.com/repos/" + user + "/" + userRepo + "/hooks/" + nID + "/test")
33+
assert(res.ping_url == "https://api.github.com/repos/" + user + "/" + userRepo + "/hooks/" + nID + "/pings")
3434
assert(res.name == "web")
3535
assert(res.events == Seq("*"))
3636
assert(res.active == true)
@@ -42,8 +42,8 @@ class WebhookOpSpec extends FunSpec with Constants with BeforeAndAfter {
4242
}
4343

4444
describe("getWebhook(owner, repo, id)") {
45-
it("should succeed with valid organization, repo and id.") {
46-
Await.result(api.getWebhook(organization, repo, nID), TIMEOUT).map { res =>
45+
it("should succeed with valid user, repo and id.") {
46+
Await.result(api.getWebhook(user, userRepo, nID), TIMEOUT).map { res =>
4747
assert(res.id == nID)
4848
}
4949
}
@@ -52,49 +52,49 @@ class WebhookOpSpec extends FunSpec with Constants with BeforeAndAfter {
5252
describe("updateWebhook(owner, repo, id, input)") {
5353
it("should succeed updating by rewriting events.") {
5454
val input = WebhookUpdateInput(events=Some(Seq("create", "pull_request")))
55-
val res = Await.result(api.updateWebhook(organization, repo, nID, input), TIMEOUT)
55+
val res = Await.result(api.updateWebhook(user, userRepo, nID, input), TIMEOUT)
5656
assert(res.events == Seq("create", "pull_request"))
5757
}
5858

5959
it("should succeed updating by using add_events.") {
6060
val input = WebhookUpdateInput(add_events=Some(Seq("push")))
61-
val res = Await.result(api.updateWebhook(organization, repo, nID, input), TIMEOUT)
61+
val res = Await.result(api.updateWebhook(user, userRepo, nID, input), TIMEOUT)
6262
assert(res.config.url == Some(targetURL))
6363
assert(res.events == Seq("create", "pull_request", "push"))
6464
}
6565

6666
it("should succeed updating by using remove_events.") {
6767
val input = WebhookUpdateInput(remove_events=Some(Seq("pull_request")))
68-
val res = Await.result(api.updateWebhook(organization, repo, nID, input), TIMEOUT)
68+
val res = Await.result(api.updateWebhook(user, userRepo, nID, input), TIMEOUT)
6969
assert(res.config.url == Some(targetURL))
7070
assert(res.events == Seq("create", "push"))
7171
}
7272

7373
it("should succeed updating by rewriting config.") {
7474
val config = WebhookConfig(targetURL)
7575
val input = WebhookUpdateInput(Some(config))
76-
val res = Await.result(api.updateWebhook(organization, repo, nID, input), TIMEOUT)
76+
val res = Await.result(api.updateWebhook(user, userRepo, nID, input), TIMEOUT)
7777
assert(res.config.url == Some(targetURL))
7878
}
7979
}
8080

8181
describe("testWebhook(owner, repo, id)") {
8282
it("should succeed with valid inputs.") {
83-
val result = Await.result(api.testWebhook(organization, repo, nID), TIMEOUT)
83+
val result = Await.result(api.testWebhook(user, userRepo, nID), TIMEOUT)
8484
assert(result == true)
8585
}
8686
}
8787

8888
describe("pingWebhook(owner, repo, id)") {
8989
it("should succeed with valid inputs.") {
90-
val result = Await.result(api.pingWebhook(organization, repo, nID), TIMEOUT)
90+
val result = Await.result(api.pingWebhook(user, userRepo, nID), TIMEOUT)
9191
assert(result == true)
9292
}
9393
}
9494

9595
describe("removeWebhook(owner, repo, id)") {
9696
it("should succeed with valid inputs.") {
97-
val result = Await.result(api.removeWebhook(organization, repo, nID), TIMEOUT)
97+
val result = Await.result(api.removeWebhook(user, userRepo, nID), TIMEOUT)
9898
assert(result == true)
9999
}
100100
}

test.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
This readme documents the changes to the tests.
33

44
## Initial Setup
5-
1. Please export username and repository that exists under your name.
5+
1. Create new repo for test on your GitHub account
6+
1. Export username and repository that exists under your name.
67
2. If you have no yet exported your Github token, create one [here](https://github.com/settings/tokens) and export it.
78

89
``` bash

0 commit comments

Comments
 (0)