-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix paging requests when using advanced query (#134)
When using `query` in `BuildsApi.getBuildsFlow`, paging responses would be incorrect because requests after the 1st would be missing the `query` parameter. For example: ``` ?since=0&query="user:gabriel.feo"&maxBuilds=1000 ?fromBuild=X&maxBuilds=1000 ... ``` Also move `GradleEnterpriseApiIntegrationTest` to correct package.
- Loading branch information
1 parent
2b8cdf8
commit 8b363bb
Showing
6 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
9 changes: 3 additions & 6 deletions
9
...nal/GradleEnterpriseApiIntegrationTest.kt → ...api/GradleEnterpriseApiIntegrationTest.kt
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
33 changes: 33 additions & 0 deletions
33
...tionTest/kotlin/com/gabrielfeo/gradle/enterprise/api/extension/BuildsApiExtensionsTest.kt
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,33 @@ | ||
package com.gabrielfeo.gradle.enterprise.api.extension | ||
|
||
import com.gabrielfeo.gradle.enterprise.api.* | ||
import com.gabrielfeo.gradle.enterprise.api.internal.* | ||
import kotlinx.coroutines.flow.collect | ||
import kotlinx.coroutines.flow.take | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.jupiter.api.* | ||
import org.junit.jupiter.api.Assertions.* | ||
|
||
class BuildsApiExtensionsTest { | ||
|
||
@Test | ||
fun getBuildsFlowUsesQueryInAllRequests() = runTest { | ||
env = RealEnv | ||
keychain = RealKeychain(RealSystemProperties) | ||
val recorder = RequestRecorder() | ||
val api = buildApi(recorder) | ||
api.buildsApi.getBuildsFlow(since = 0, query = "user:*").take(2000).collect() | ||
recorder.requests.forEachIndexed { i, request -> | ||
assertEquals("user:*", request.url.queryParameter("query"), "[$i]") | ||
} | ||
api.shutdown() | ||
} | ||
|
||
private fun buildApi(recorder: RequestRecorder) = | ||
GradleEnterpriseApi.newInstance( | ||
config = Config( | ||
clientBuilder = recorder.clientBuilder(), | ||
cacheConfig = Config.CacheConfig(cacheEnabled = false), | ||
) | ||
) | ||
} |
16 changes: 16 additions & 0 deletions
16
.../integrationTest/kotlin/com/gabrielfeo/gradle/enterprise/api/extension/RequestRecorder.kt
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,16 @@ | ||
package com.gabrielfeo.gradle.enterprise.api.extension | ||
|
||
import okhttp3.OkHttpClient | ||
import okhttp3.Request | ||
import java.util.* | ||
|
||
class RequestRecorder { | ||
|
||
val requests = LinkedList<Request>() | ||
|
||
fun clientBuilder() = OkHttpClient.Builder() | ||
.addNetworkInterceptor { | ||
requests += it.request() | ||
it.proceed(it.request()) | ||
} | ||
} |
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
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