Skip to content

Commit

Permalink
Test Marking release (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
jraska authored Mar 20, 2021
1 parent 267f1b2 commit bbcd824
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
applicationId "com.jraska.github.client"
minSdkVersion 24
targetSdkVersion 30
versionName '0.23.1'
versionCode 88
versionName '0.23.2'
versionCode 89
multiDexEnabled true

testInstrumentationRunner "com.jraska.github.client.TestRunner"
Expand Down
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ext {
okHttpVersion = '4.9.1'
okHttp = "com.squareup.okhttp3:okhttp:$okHttpVersion"
okHttpLoggingInterceptor = "com.squareup.okhttp3:logging-interceptor:$okHttpVersion"
okHttpMockWebServer = "com.squareup.okhttp3:mockwebserver:$okHttpVersion"

frescoVesion = '2.4.0'
fresco = "com.facebook.fresco:fresco:$frescoVesion"
Expand Down
1 change: 1 addition & 0 deletions plugins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies {

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.assertj:assertj-core:3.19.0'
testImplementation okHttpMockWebServer
}

compileKotlin {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.jraska.github.client.release

import com.jraska.github.client.release.data.GitHubApiFactory
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import org.assertj.core.api.Assertions.assertThat
import org.junit.Rule
import org.junit.Test

class GitHubApiImplTest {

@get:Rule
val mockWebServer = MockWebServer()

@Test
fun testPrMarkedProperly() {
val environment = Environment("fakeToken", mockWebServer.url("/"))
val gitHubApi = GitHubApiFactory.create(environment)

mockWebServer.enqueue(MockResponse().setResponseCode(200).setBody("{\"url\":\"https://api.github.com/repos/jraska/github-client/releases/40105170\",\"assets_url\":\"https://api.github.com/repos/jraska/github-client/releases/40105170/assets\",\"upload_url\":\"https://uploads.github.com/repos/jraska/github-client/releases/40105170/assets{?name,label}\",\"html_url\":\"https://github.com/jraska/github-client/releases/tag/0.23.0\",\"id\":40105170,\"author\":{\"login\":\"jraska\",\"id\":6277721,\"node_id\":\"MDQ6VXNlcjYyNzc3MjE=\",\"avatar_url\":\"https://avatars.githubusercontent.com/u/6277721?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/jraska\",\"html_url\":\"https://github.com/jraska\",\"followers_url\":\"https://api.github.com/users/jraska/followers\",\"following_url\":\"https://api.github.com/users/jraska/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/jraska/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/jraska/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/jraska/subscriptions\",\"organizations_url\":\"https://api.github.com/users/jraska/orgs\",\"repos_url\":\"https://api.github.com/users/jraska/repos\",\"events_url\":\"https://api.github.com/users/jraska/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/jraska/received_events\",\"type\":\"User\",\"site_admin\":false},\"node_id\":\"MDc6UmVsZWFzZTQwMTA1MTcw\",\"tag_name\":\"0.23.0\",\"target_commitish\":\"master\",\"name\":\"0.23.0\",\"draft\":false,\"prerelease\":false,\"created_at\":\"2021-03-20T16:30:43Z\",\"published_at\":\"2021-03-20T16:31:04Z\",\"assets\":[],\"tarball_url\":\"https://api.github.com/repos/jraska/github-client/tarball/0.23.0\",\"zipball_url\":\"https://api.github.com/repos/jraska/github-client/zipball/0.23.0\",\"body\":\"Hey hey\"}\n"))
mockWebServer.enqueue(MockResponse().setResponseCode(200))

gitHubApi.setReleaseBody("0.23.0", "Hey hallo")

assertThat(mockWebServer.takeRequest().requestUrl!!.encodedPath).endsWith("/releases/tags/0.23.0")

val secondRequest = mockWebServer.takeRequest()
assertThat(secondRequest.requestUrl!!.encodedPath.endsWith("releases/40105170"))
assertThat(secondRequest.body.toString()).contains("{\"body\":\"Hey hallo\"}")
}
}

0 comments on commit bbcd824

Please sign in to comment.