-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
208 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
github4s/shared/src/test/scala/github4s/integration/GHOrganizationsSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2016-2017 47 Degrees, LLC. <http://www.47deg.com> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package github4s.integration | ||
|
||
import github4s.Github | ||
import github4s.Github._ | ||
import github4s.free.domain.User | ||
import github4s.implicits._ | ||
import github4s.utils.BaseIntegrationSpec | ||
|
||
trait GHOrganizationsSpec[T] extends BaseIntegrationSpec[T] { | ||
|
||
"Organization >> ListMembers" should "return the expected list of users" in { | ||
val response = | ||
Github(accessToken).organizations | ||
.listMembers(validRepoOwner) | ||
.execFuture[T](headerUserAgent) | ||
|
||
testFutureIsRight[List[User]](response, { r => | ||
r.result.nonEmpty shouldBe true | ||
r.statusCode shouldBe okStatusCode | ||
}) | ||
} | ||
|
||
it should "return error for an invalid org" in { | ||
val response = | ||
Github(accessToken).organizations | ||
.listMembers(invalidUsername) | ||
.execFuture[T](headerUserAgent) | ||
|
||
testFutureIsLeft(response) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
github4s/shared/src/test/scala/github4s/unit/GHOrganizationsSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2016-2017 47 Degrees, LLC. <http://www.47deg.com> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package github4s.unit | ||
|
||
import cats.free.Free | ||
import github4s.GithubResponses.{GHResponse, GHResult} | ||
import github4s.{GHOrganizations, HttpClient} | ||
import github4s.app.GitHub4s | ||
import github4s.free.domain.User | ||
import github4s.utils.BaseSpec | ||
|
||
class GHOrganizationsSpec extends BaseSpec { | ||
|
||
"Organizations.listMembers" should "call to OrganizationsOps with the right parameters" in { | ||
|
||
val response: Free[GitHub4s, GHResponse[List[User]]] = | ||
Free.pure(Right(GHResult(List(user), okStatusCode, Map.empty))) | ||
|
||
val organizationOps = mock[OrganizationOpsTest] | ||
(organizationOps.listMembers _) | ||
.expects(validRepoOwner, None, None, None, sampleToken) | ||
.returns(response) | ||
|
||
val ghOrganizations = new GHOrganizations(sampleToken)(organizationOps) | ||
ghOrganizations.listMembers(validRepoOwner) | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
github4s/shared/src/test/scala/github4s/unit/OrganizationssSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2016-2017 47 Degrees, LLC. <http://www.47deg.com> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package github4s.unit | ||
|
||
import cats.Id | ||
import github4s.GithubResponses.{GHResponse, GHResult} | ||
import github4s.HttpClient | ||
import github4s.api.Organizations | ||
import github4s.free.domain.User | ||
import github4s.utils.BaseSpec | ||
|
||
class OrganizationsSpec extends BaseSpec { | ||
|
||
"Organization.listMembers" should "call to httpClient.get with the right parameters" in { | ||
|
||
val response: GHResponse[List[User]] = | ||
Right(GHResult(List(user), okStatusCode, Map.empty)) | ||
|
||
val httpClientMock = httpClientMockGet[List[User]]( | ||
url = s"orgs/$validRepoOwner/members", | ||
response = response | ||
) | ||
|
||
val organizations = new Organizations[String, Id] { | ||
override val httpClient: HttpClient[String, Id] = httpClientMock | ||
} | ||
organizations.listMembers(sampleToken, headerUserAgent, validRepoOwner) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters