Skip to content

fix Linux Event Test#148

Merged
irgaly merged 1 commit intomainfrom
fix_linuxevent
Apr 13, 2023
Merged

fix Linux Event Test#148
irgaly merged 1 commit intomainfrom
fix_linuxevent

Conversation

@irgaly
Copy link
Copy Markdown
Owner

@irgaly irgaly commented Apr 13, 2023

Linux Event Test が Coroutine のタイミングで数回に1回程度失敗することがあった。

@irgaly irgaly self-assigned this Apr 13, 2023
// イベント送信漏れが発生しないように SUSPEND
onBufferOverflow = BufferOverflow.SUSPEND
)
private val lastEvent = source.map {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map { } は、Dispatcher の都合により遅延実行されることがあり、テストでイベントの発行が重複することがあった。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map を使わないようにして解決

it.eventType shouldBe KottageEventType.Create
cache.eventFlow().let { flow ->
flow.test {
flow.ensureSubscribed()
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KottageEventFlow は subscribe 完了まで短い時間 suspend されることがある。
Turbine は subscribe での suspend を待たないため、ensureSubscribed() で待てるようにした。

@irgaly irgaly merged commit 219031a into main Apr 13, 2023
@irgaly irgaly deleted the fix_linuxevent branch April 13, 2023 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant