Skip to content

Commit

Permalink
Make the integration tests skippable, fixes #178
Browse files Browse the repository at this point in the history
  • Loading branch information
BenFradet committed Apr 10, 2019
1 parent 53856fa commit 09b9a52
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 116 deletions.
63 changes: 32 additions & 31 deletions github4s/jvm/src/test/scala/github4s/unit/ApiSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import cats.implicits._
import scalaj.http._
import cats.Id
import github4s.jvm.ImplicitsJVM
import github4s.utils.Integration

class ApiSpec
extends FlatSpec
Expand Down Expand Up @@ -331,7 +332,7 @@ class ApiSpec
response should be('left)
}

"Repos >> CreateRelease" should "return the created release" in {
"Repos >> CreateRelease" should "return the created release" taggedAs Integration in {
val response =
repos.createRelease(
accessToken,
Expand Down Expand Up @@ -360,7 +361,7 @@ class ApiSpec
response should be('left)
}

"Repos >> GetStatus" should "return the expected combined status when a valid ref is provided" in {
"Repos >> GetStatus" should "return the expected combined status when a valid ref is provided" taggedAs Integration in {
val response =
repos.getStatus(accessToken, headerUserAgent, validRepoOwner, validRepoName, validRefSingle)
response should be('right)
Expand All @@ -380,7 +381,7 @@ class ApiSpec
response should be('left)
}

"Repos >> ListStatus" should "return the expected statuses when a valid ref is provided" in {
"Repos >> ListStatus" should "return the expected statuses when a valid ref is provided" taggedAs Integration in {
val response = repos.listStatuses(
accessToken,
headerUserAgent,
Expand Down Expand Up @@ -410,7 +411,7 @@ class ApiSpec
}
}

"Repos >> CreateStatus" should "return the created status if a valid sha is provided" in {
"Repos >> CreateStatus" should "return the created status if a valid sha is provided" taggedAs Integration in {
val response = repos.createStatus(
accessToken,
headerUserAgent,
Expand Down Expand Up @@ -467,7 +468,7 @@ class ApiSpec
val response = users.get(accessToken, headerUserAgent, invalidUsername)
response should be('left)
}
"Users >> GetAuth" should "return the expected login for a valid accessToken" in {
"Users >> GetAuth" should "return the expected login for a valid accessToken" taggedAs Integration in {
val response = users.getAuth(accessToken, headerUserAgent)
response should be('right)

Expand Down Expand Up @@ -501,7 +502,7 @@ class ApiSpec
}
}

"Gists >> PostGist" should "return the provided gist for a valid request" in {
"Gists >> PostGist" should "return the provided gist for a valid request" taggedAs Integration in {
val response =
gists.newGist(
validGistDescription,
Expand All @@ -516,7 +517,7 @@ class ApiSpec
}
}

"Gists >> GetGist" should "return the single gist for a valid request" in {
"Gists >> GetGist" should "return the single gist for a valid request" taggedAs Integration in {
val response =
gists.getGist(validGistId, sha = None, headerUserAgent, accessToken)
response should be('right)
Expand All @@ -526,7 +527,7 @@ class ApiSpec
}
}

it should "return the specific revision of gist for a valid request" in {
it should "return the specific revision of gist for a valid request" taggedAs Integration in {
val response =
gists.getGist(validGistId, sha = Some(validGistSha), headerUserAgent, accessToken)
response should be('right)
Expand All @@ -536,7 +537,7 @@ class ApiSpec
}
}

"Gists >> EditGist" should "return the provided gist for a valid request" in {
"Gists >> EditGist" should "return the provided gist for a valid request" taggedAs Integration in {
val response =
gists.editGist(
validGistId,
Expand Down Expand Up @@ -586,7 +587,7 @@ class ApiSpec
response should be('left)
}

"GitData >> CreateReference" should "return the single reference" in {
"GitData >> CreateReference" should "return the single reference" taggedAs Integration in {
val response =
gitData.createReference(
accessToken,
Expand All @@ -613,7 +614,7 @@ class ApiSpec
response should be('left)
}

"GitData >> UpdateReference" should "return the single reference" in {
"GitData >> UpdateReference" should "return the single reference" taggedAs Integration in {
val response =
gitData.updateReference(
accessToken,
Expand Down Expand Up @@ -655,7 +656,7 @@ class ApiSpec
response should be('left)
}

"GitData >> CreateCommit" should "return the single commit" in {
"GitData >> CreateCommit" should "return the single commit" taggedAs Integration in {
val response =
gitData.createCommit(
accessToken,
Expand Down Expand Up @@ -684,7 +685,7 @@ class ApiSpec
response should be('left)
}

"GitData >> CreateBlob" should "return the created blob" in {
"GitData >> CreateBlob" should "return the created blob" taggedAs Integration in {
val response =
gitData.createBlob(accessToken, headerUserAgent, validRepoOwner, validRepoName, validNote)
response should be('right)
Expand All @@ -699,7 +700,7 @@ class ApiSpec
response should be('left)
}

"GitData >> CreateTree" should "return the created tree" in {
"GitData >> CreateTree" should "return the created tree" taggedAs Integration in {
val response =
gitData.createTree(
accessToken,
Expand Down Expand Up @@ -836,7 +837,7 @@ class ApiSpec
response should be('left)
}

"PullRequests >> List PullRequestReviews" should "return a list of reviews when valid data is provided" in {
"PullRequests >> List PullRequestReviews" should "return a list of reviews when valid data is provided" taggedAs Integration in {
val response = pullRequests.listReviews(
accessToken,
headerUserAgent,
Expand All @@ -855,7 +856,7 @@ class ApiSpec
response should be('left)
}

"PullRequests >> Get PullRequestReview" should "return a single review when valid data is provided" in {
"PullRequests >> Get PullRequestReview" should "return a single review when valid data is provided" taggedAs Integration in {
val response = pullRequests.getReview(
accessToken,
headerUserAgent,
Expand All @@ -876,7 +877,7 @@ class ApiSpec
response should be('left)
}

"Issues >> List" should "return the expected issues when a valid owner/repo is provided" in {
"Issues >> List" should "return the expected issues when a valid owner/repo is provided" taggedAs Integration in {
val response =
issues.list(accessToken, headerUserAgent, validRepoOwner, validRepoName)
response should be('right)
Expand All @@ -897,7 +898,7 @@ class ApiSpec
response should be('left)
}

"Issues >> Get" should "return the expected issue when a valid owner/repo is provided" in {
"Issues >> Get" should "return the expected issue when a valid owner/repo is provided" taggedAs Integration in {
val response =
issues.get(accessToken, headerUserAgent, validRepoOwner, validRepoName, validIssueNumber)
response should be('right)
Expand All @@ -906,7 +907,7 @@ class ApiSpec
r.statusCode shouldBe okStatusCode
}
}
it should "return an issue which is just a Pull Request" in {
it should "return an issue which is just a Pull Request" taggedAs Integration in {
val response =
issues.get(
accessToken,
Expand All @@ -927,7 +928,7 @@ class ApiSpec
response should be('left)
}

"Issues >> Create" should "return the created issue if valid data is provided" in {
"Issues >> Create" should "return the created issue if valid data is provided" taggedAs Integration in {
val response = issues.create(
accessToken,
headerUserAgent,
Expand Down Expand Up @@ -971,7 +972,7 @@ class ApiSpec
response should be('left)
}

"Issues >> Edit" should "return the edited issue if valid data is provided" in {
"Issues >> Edit" should "return the edited issue if valid data is provided" taggedAs Integration in {
val response = issues.edit(
accessToken,
headerUserAgent,
Expand Down Expand Up @@ -1021,15 +1022,15 @@ class ApiSpec
response should be('left)
}

"Issues >> Search" should "return the search result if valid data is provided" in {
"Issues >> Search" should "return the search result if valid data is provided" taggedAs Integration in {
val response = issues.search(accessToken, headerUserAgent, validSearchQuery, List.empty)
response should be('right)

response.toOption map { r =>
r.statusCode shouldBe okStatusCode
}
}
it should "return an empty result if a search query matching nothing is provided" in {
it should "return an empty result if a search query matching nothing is provided" taggedAs Integration in {
val response =
issues.search(accessToken, headerUserAgent, nonExistentSearchQuery, List.empty)
response should be('right)
Expand All @@ -1040,7 +1041,7 @@ class ApiSpec
}
}

"Issues >> ListComments" should "return the expected issue comments when a valid issue number is provided" in {
"Issues >> ListComments" should "return the expected issue comments when a valid issue number is provided" taggedAs Integration in {
val response =
issues.listComments(
accessToken,
Expand Down Expand Up @@ -1071,7 +1072,7 @@ class ApiSpec
response should be('left)
}

"Issues >> Create a Comment" should "return the comment created when a valid issue number is provided" in {
"Issues >> Create a Comment" should "return the comment created when a valid issue number is provided" taggedAs Integration in {
val response =
issues.createComment(
accessToken,
Expand Down Expand Up @@ -1105,7 +1106,7 @@ class ApiSpec
response should be('left)
}

"Issues >> Edit a Comment" should "return the edited comment when a valid comment id is provided" in {
"Issues >> Edit a Comment" should "return the edited comment when a valid comment id is provided" taggedAs Integration in {
val response =
issues.editComment(
accessToken,
Expand Down Expand Up @@ -1139,7 +1140,7 @@ class ApiSpec
response should be('left)
}

"Issues >> Delete a Comment" should "return deleted status when a valid comment id is provided" in {
"Issues >> Delete a Comment" should "return deleted status when a valid comment id is provided" taggedAs Integration in {
val response =
issues.deleteComment(
accessToken,
Expand All @@ -1165,7 +1166,7 @@ class ApiSpec
response should be('left)
}

"Issues >> ListLabels" should "return the expected issue labels when a valid issue number is provided" in {
"Issues >> ListLabels" should "return the expected issue labels when a valid issue number is provided" taggedAs Integration in {
val response =
issues.listLabels(
accessToken,
Expand Down Expand Up @@ -1196,7 +1197,7 @@ class ApiSpec
response should be('left)
}

"Issues >> RemoveLabel" should "return the removed issue labels when a valid issue number is provided" in {
"Issues >> RemoveLabel" should "return the removed issue labels when a valid issue number is provided" taggedAs Integration in {
val response =
issues.removeLabel(
accessToken,
Expand Down Expand Up @@ -1235,7 +1236,7 @@ class ApiSpec
response should be('left)
}

"Issues >> AddLabels" should "return the assigned issue labels when a valid issue number is provided" in {
"Issues >> AddLabels" should "return the assigned issue labels when a valid issue number is provided" taggedAs Integration in {
val response =
issues.addLabels(
accessToken,
Expand Down Expand Up @@ -1325,7 +1326,7 @@ class ApiSpec
}
}

"Activities >> Set a Thread Subscription" should "return the subscription when a valid thread id is provided" in {
"Activities >> Set a Thread Subscription" should "return the subscription when a valid thread id is provided" taggedAs Integration in {
val response =
activities.setThreadSub(accessToken, headerUserAgent, validThreadId, true, false)
response should be('right)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import github4s.Github
import github4s.Github._
import github4s.free.domain.{Stargazer, StarredRepository, Subscription}
import github4s.implicits._
import github4s.utils.BaseIntegrationSpec
import github4s.utils.{BaseIntegrationSpec, Integration}

trait GHActivitiesSpec[T] extends BaseIntegrationSpec[T] {

"Activity >> Set a thread subscription" should "return expected response when a valid thread id is provided" in {
"Activity >> Set a thread subscription" should "return expected response when a valid thread id is provided" taggedAs Integration in {
val response =
Github(accessToken).activities
.setThreadSub(validThreadId, true, false)
Expand All @@ -35,7 +35,7 @@ trait GHActivitiesSpec[T] extends BaseIntegrationSpec[T] {
})
}

it should "return error when an invalid thread id is passed" in {
it should "return error when an invalid thread id is passed" taggedAs Integration in {
val response =
Github(accessToken).activities
.setThreadSub(invalidThreadId, true, false)
Expand All @@ -44,8 +44,7 @@ trait GHActivitiesSpec[T] extends BaseIntegrationSpec[T] {
testFutureIsLeft(response)
}


"Activity >> ListStargazers" should "return the expected list of starrers for valid data" in {
"Activity >> ListStargazers" should "return the expected list of starrers for valid data" taggedAs Integration in {
val response =
Github(accessToken).activities
.listStargazers(validRepoOwner, validRepoName, false)
Expand All @@ -58,7 +57,7 @@ trait GHActivitiesSpec[T] extends BaseIntegrationSpec[T] {
})
}

it should "return the expected list of starrers for valid data with dates if timeline" in {
it should "return the expected list of starrers for valid data with dates if timeline" taggedAs Integration in {
val response =
Github(accessToken).activities
.listStargazers(validRepoOwner, validRepoName, true)
Expand All @@ -80,7 +79,7 @@ trait GHActivitiesSpec[T] extends BaseIntegrationSpec[T] {
testFutureIsLeft(response)
}

"Activity >> ListStarredRepositories" should "return the expected list of starred repos" in {
"Activity >> ListStarredRepositories" should "return the expected list of starred repos" taggedAs Integration in {
val response =
Github(accessToken).activities
.listStarredRepositories(validUsername, false)
Expand All @@ -93,7 +92,7 @@ trait GHActivitiesSpec[T] extends BaseIntegrationSpec[T] {
})
}

it should "return the expected list of starred repos with dates if timeline" in {
it should "return the expected list of starred repos with dates if timeline" taggedAs Integration in {
val response =
Github(accessToken).activities
.listStarredRepositories(validUsername, true)
Expand All @@ -106,7 +105,7 @@ trait GHActivitiesSpec[T] extends BaseIntegrationSpec[T] {
})
}

it should "return error for invalid username" in {
it should "return error for invalid username" taggedAs Integration in {
val response =
Github(accessToken).activities
.listStarredRepositories(invalidUsername, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import github4s.Github
import github4s.Github._
import github4s.free.domain.Authorize
import github4s.implicits._
import github4s.utils.BaseIntegrationSpec
import github4s.utils.{BaseIntegrationSpec, Integration}

trait GHAuthSpec[T] extends BaseIntegrationSpec[T] {

"Auth >> NewAuth" should "return error on Left when invalid credential is provided" in {
"Auth >> NewAuth" should "return error on Left when invalid credential is provided" taggedAs Integration in {

val response = Github().auth
.newAuth(
Expand All @@ -39,7 +39,7 @@ trait GHAuthSpec[T] extends BaseIntegrationSpec[T] {
testFutureIsLeft(response)
}

"Auth >> AuthorizeUrl" should "return the expected URL for valid username" in {
"Auth >> AuthorizeUrl" should "return the expected URL for valid username" taggedAs Integration in {
val response =
Github().auth
.authorizeUrl(validClientId, validRedirectUri, validScopes)
Expand All @@ -51,7 +51,7 @@ trait GHAuthSpec[T] extends BaseIntegrationSpec[T] {
})
}

"Auth >> GetAccessToken" should "return error on Left for invalid code value" in {
"Auth >> GetAccessToken" should "return error on Left for invalid code value" taggedAs Integration in {
val response = Github().auth
.getAccessToken(validClientId, invalidClientSecret, "", validRedirectUri, "")
.execFuture[T](headerUserAgent)
Expand Down

0 comments on commit 09b9a52

Please sign in to comment.