-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathStatusOpSpec.scala
76 lines (61 loc) · 2.43 KB
/
StatusOpSpec.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package codecheck.github
package operations
import models._
import codecheck.github.models.Status
import codecheck.github.models.StatusInput
import codecheck.github.models.StatusState
import exceptions._
import codecheck.github.exceptions.GitHubAPIException
import codecheck.github.exceptions.NotFoundException
import org.scalatest.FunSpec
import scala.concurrent.Await
class StatusOpSpec extends FunSpec with api.Constants {
describe("listStatus(owner, repo, sha)") {
it("should have zero or more statuses") {
val result = Await.result(api.listStatus(user, userRepo, userSha), TIMEOUT)
result.map { status =>
assert(StatusState.values.contains(status.state))
}
}
}
describe("getStatus(owner, repo, sha)") {
it("should have a status or not") {
val result = Await.result(api.getStatus(user, userRepo, userSha), TIMEOUT)
assert(StatusState.values.contains(result.state))
assert(result.sha == userSha)
assert(result.total_count >= 0L)
assert(result.statuses.length >= 0L)
result.statuses.map { status =>
assert(StatusState.values.contains(status.state))
}
}
}
describe("createStatus(owner, repo, sha, input)") {
it("should be pending") {
val input = StatusInput(StatusState.pending)
val result = Await.result(api.createStatus(user, userRepo, userSha, input), TIMEOUT)
assert(result.state == StatusState.pending)
assert(result.target_url == None)
assert(result.description == None)
assert(result.context == "default")
}
it("should be success") {
val input = StatusInput(StatusState.success, Some("http://"))
val result = Await.result(api.createStatus(user, userRepo, userSha, input), TIMEOUT)
assert(result.state == StatusState.success)
assert(result.target_url == Some("http://"))
}
it("should be error") {
val input = StatusInput(StatusState.error, description = Some("Description"))
val result = Await.result(api.createStatus(user, userRepo, userSha, input), TIMEOUT)
assert(result.state == StatusState.error)
assert(result.description == Some("Description"))
}
it("should be failure") {
val input = StatusInput(StatusState.failure, context = Some("context"))
val result = Await.result(api.createStatus(user, userRepo, userSha, input), TIMEOUT)
assert(result.state == StatusState.failure)
assert(result.context == "context")
}
}
}