11import org .scalatest .path .FunSpec
2- import codecheck .github .models .Collaborator
32import scala .concurrent .Await
3+ import codecheck .github .models .Collaborator
4+ import codecheck .github .exceptions .GitHubAPIException
5+ import codecheck .github .exceptions .NotFoundException
46
57class CollaboratorOpSpec extends FunSpec with Constants {
68
@@ -16,4 +18,44 @@ class CollaboratorOpSpec extends FunSpec with Constants {
1618 assert(c.site_admin == false )
1719 }
1820 }
21+ describe(" isCollaborator" ){
22+ it(" if it is Collaborator" ){
23+ val res = Await .result(api.addCollaborator(user, userRepo, collaboratorUser),TIMEOUT )
24+ assert(res)
25+ val res1 = Await .result(api.isCollaborator(user, userRepo, collaboratorUser),TIMEOUT )
26+ assert(res1 == true )
27+ var res2 = Await .result(api.removeCollaborator(user, userRepo, collaboratorUser),TIMEOUT )
28+ assert(res2)
29+ }
30+ it(" if it is not a valid Collaborator" ){
31+ val res1 = Await .result(api.isCollaborator(organization, repo, otherUserInvalid),TIMEOUT )
32+ assert(res1 == false )
33+ }
34+ }
35+ describe(" addCollaborator" ){
36+ it(" should add Collaborator User to user Repo" ){
37+ val res = Await .result(api.addCollaborator(user, userRepo, collaboratorUser),TIMEOUT )
38+ assert(res)
39+ }
40+ it(" should fail for non existent User Repo" ){
41+ val res = Await .result(api.addCollaborator(user, repoInvalid, collaboratorUser).failed,TIMEOUT )
42+ res match {
43+ case e : NotFoundException =>
44+ case _ => fail
45+ }
46+ }
47+ }
48+ describe(" removeCollaborator" ){
49+ it(" should remove the Collaborator" ){
50+ var res = Await .result(api.removeCollaborator(user, userRepo, collaboratorUser),TIMEOUT )
51+ assert(res)
52+ }
53+ }
54+ it(" should fail for non existent User Repo" ){
55+ var res = Await .result(api.removeCollaborator(user, repoInvalid, collaboratorUser).failed,TIMEOUT )
56+ res match {
57+ case e : NotFoundException =>
58+ case _ => fail
59+ }
60+ }
1961}
0 commit comments