Skip to content

Commit

Permalink
Update GithubMockServerHandler.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
piotradamczyk5 authored and Piotr Adamczyk committed Nov 20, 2020
1 parent 7ae1bea commit bd87d68
Showing 1 changed file with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,12 @@ import kotlinx.serialization.json.Json

fun handleGithubMockRequest(url: String, request: Request) = when {
url.endsWith("/git/refs/tags/success") -> request.buildResponse("", 200)
url.endsWith("/releases/latest") && request.containsSuccessHeader() -> request.buildResponse(
GitHubRelease("v20.08.0").toJson(),
200
)
url.endsWith("/releases/latest") && request.containsSuccessHeader() ->
request.buildResponse(GitHubRelease("v20.08.0").toJson(), 200)
url.endsWith("/commits/success/pulls") -> request.buildResponse(Json.encodeToString(githubPullRequestTest), 200)
url.endsWith("/labels") && request.containsSuccessHeader() -> request.buildResponse(
testGithubLabels.toJson(), 200
)
(url.contains("/pulls/") || url.contains("/issues/")) && request.containsSuccessHeader() -> request.buildResponse(
githubPullRequestTest.first().toJson(), 200
)
url.endsWith("/labels") && request.containsSuccessHeader() -> request.buildResponse(testGithubLabels.toJson(), 200)
(url.contains("/pulls/") || url.contains("/issues/")) && request.containsSuccessHeader() ->
request.buildResponse(githubPullRequestTest.first().toJson(), 200)
request.isFailedGithubRequest() -> request.buildResponse(githubErrorBody, 422)
else -> error("Not supported request")
}
Expand Down

0 comments on commit bd87d68

Please sign in to comment.