Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Update streaming tests to the new testApplication API #20

Open
goncalossilva opened this issue Jan 14, 2022 · 0 comments
Open

Update streaming tests to the new testApplication API #20

goncalossilva opened this issue Jan 14, 2022 · 0 comments
Labels
enhancement New feature or request server Specific to the server

Comments

@goncalossilva
Copy link
Member

Events are sent, but never received. I suspect it's down to both server and client running on the same process during testing, sharing the same coroutines dispatcher, and going into a deadlock. Unfortunately, it's not possible to configure the dispatcher of either to validate this assumption. They both use Dispartchers.IO and there are plans to provide ways to override them, but probably not soon.

The header documents the high-level approach I went for:

* @Test
* fun testStreamGet() = testApplication {
* val client = createTokenClient(Permission.READ)
* val projectId = client.projectId
* var eventCount = 0
*
* client.userClient.client.post("${PATH_PROJECT(projectId)}$PATH_FLAGS") {
* setBodyForm("name" to "test", "rule" to "true")
* }
*
* client.client.launch {
* client.client.stream(PATH_FLAGS) {
* eventCount++
* val flags = json.decodeFromString<List<Flag>>(it.data)
* assert(flags.size == 1)
* assert(flags[0].name == "test")
* assert(flags[0].rule == "true")
* }
* }
*
* client.userClient.client.post("${PATH_PROJECT(projectId)}$PATH_FLAGS") {
* setBodyForm("name" to "test", "rule" to "true")
* }
*
* assert(eventCount == 1)
* }

@goncalossilva goncalossilva added enhancement New feature or request server Specific to the server labels Jan 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request server Specific to the server
Projects
None yet
Development

No branches or pull requests

1 participant