Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a testing module for soil-query 🧪 #63

Merged
merged 1 commit into from
Aug 11, 2024
Merged

Conversation

ogaclejapan
Copy link
Contributor

We provide a testing package that enhances testability by introducing a mocking mechanism for executing query and mutation blocks. This capability enables the execution of tests without the need for actual API communication, thereby increasing test independence.

@Test
fun testQuery() = runTest {
    val client = SwrCache(
        policy = SwrCachePolicy(
            coroutineScope = backgroundScope,
            mainDispatcher = UnconfinedTestDispatcher(testScheduler)
        )
    )
    val testClient = client.test().apply {
        mock(ExampleQueryKey.Id) {
            "Hello, World!"
        }
    }
    val key = ExampleQueryKey()
    val query = testClient.getQuery(key).also { it.launchIn(backgroundScope) }
    query.test()
    assertEquals("Hello, World!", query.state.value.data)
}

We provide a testing package that enhances testability by introducing a mocking mechanism for executing query and
mutation blocks. This capability enables the execution of tests without the need for actual API communication,
thereby increasing test independence.
@ogaclejapan ogaclejapan added the enhancement New feature or request label Aug 11, 2024
@ogaclejapan ogaclejapan merged commit 3368a47 into main Aug 11, 2024
1 check passed
@ogaclejapan ogaclejapan deleted the testing-module branch August 11, 2024 07:32
ogaclejapan added a commit that referenced this pull request Aug 25, 2024
With the enhancement of preview and test implementations, more APIs now accept `UniqueId` types as
arguments. Associating the ID definitions with a companion object helps leverage these features more effectively.

refs: #63, #70
ogaclejapan added a commit that referenced this pull request Aug 31, 2024
Aligning PreviewClient implementation and naming reduces cognitive load.

refs: #63, #70
@github-actions github-actions bot mentioned this pull request Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant