Skip to content

Commit

Permalink
Run gradlew ktlintFormat
Browse files Browse the repository at this point in the history
Signed-off-by: matt-ramotar <matt.ramotar@uber.com>
  • Loading branch information
matt-ramotar committed Nov 17, 2024
1 parent 134f87d commit 29db0a1
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 299 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,37 @@ class FetcherResponseTests {
}

@Test
fun givenAFetcherThatEmitsErrorAndDataWhenSteamingThenItCanEmitValueAfterAnError() = testScope.runTest {
val exception = RuntimeException("first error")
val store =
StoreBuilder.from(
fetcher =
Fetcher.ofResultFlow { key: Int ->
flowOf(
FetcherResult.Error.Exception(exception),
FetcherResult.Data("$key"),
)
},
).buildWithTestScope()

store.stream(StoreReadRequest.fresh(1)).test {
assertEquals(
StoreReadResponse.Loading(StoreReadResponseOrigin.Fetcher()),
awaitItem()
)

assertEquals(
StoreReadResponse.Error.Exception(exception, StoreReadResponseOrigin.Fetcher()),
awaitItem()
)

assertEquals(
StoreReadResponse.Data("1", StoreReadResponseOrigin.Fetcher()),
awaitItem()
)
}
fun givenAFetcherThatEmitsErrorAndDataWhenSteamingThenItCanEmitValueAfterAnError() =
testScope.runTest {
val exception = RuntimeException("first error")
val store =
StoreBuilder.from(
fetcher =
Fetcher.ofResultFlow { key: Int ->
flowOf(
FetcherResult.Error.Exception(exception),
FetcherResult.Data("$key"),
)
},
).buildWithTestScope()

}
store.stream(StoreReadRequest.fresh(1)).test {
assertEquals(
StoreReadResponse.Loading(StoreReadResponseOrigin.Fetcher()),
awaitItem(),
)

assertEquals(
StoreReadResponse.Error.Exception(exception, StoreReadResponseOrigin.Fetcher()),
awaitItem(),
)

assertEquals(
StoreReadResponse.Data("1", StoreReadResponseOrigin.Fetcher()),
awaitItem(),
)
}
}

@Test
fun givenTransformerWhenRawValueThenUnwrappedValueReturnedAndValueIsCached() =
Expand All @@ -79,15 +79,15 @@ class FetcherResponseTests {
StoreReadResponse.Loading(
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)

assertEquals(
StoreReadResponse.Data(
value = 9,
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)
}

Expand All @@ -97,7 +97,7 @@ class FetcherResponseTests {
value = 9,
origin = StoreReadResponseOrigin.Cache,
),
awaitItem()
awaitItem(),
)
}
}
Expand Down Expand Up @@ -125,15 +125,15 @@ class FetcherResponseTests {
StoreReadResponse.Loading(
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)

assertEquals(
StoreReadResponse.Error.Message(
message = "zero",
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)
}

Expand All @@ -142,15 +142,15 @@ class FetcherResponseTests {
StoreReadResponse.Loading(
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)

assertEquals(
StoreReadResponse.Data(
value = 1,
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)
}
}
Expand Down Expand Up @@ -180,15 +180,15 @@ class FetcherResponseTests {
StoreReadResponse.Loading(
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)

assertEquals(
StoreReadResponse.Error.Exception(
error = e,
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)
}

Expand All @@ -197,15 +197,15 @@ class FetcherResponseTests {
StoreReadResponse.Loading(
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)

assertEquals(
StoreReadResponse.Data(
value = 1,
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)
}
}
Expand All @@ -228,21 +228,20 @@ class FetcherResponseTests {
.from(fetcher = fetcher)
.buildWithTestScope()


pipeline.stream(StoreReadRequest.fresh(3)).test {
assertEquals(
StoreReadResponse.Loading(
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)

assertEquals(
StoreReadResponse.Error.Exception(
error = e,
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)
}

Expand All @@ -251,15 +250,15 @@ class FetcherResponseTests {
StoreReadResponse.Loading(
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)

assertEquals(
StoreReadResponse.Data(
value = 1,
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)
}
}
Expand All @@ -274,25 +273,25 @@ class FetcherResponseTests {
val store =
StoreBuilder.from(
fetcher =
Fetcher.ofResultFlow { _: Int ->
flowOf(
FetcherResult.Error.Custom(customError),
)
},
Fetcher.ofResultFlow { _: Int ->
flowOf(
FetcherResult.Error.Custom(customError),
)
},
).buildWithTestScope()

store.stream(StoreReadRequest.fresh(1)).test {
assertEquals(
StoreReadResponse.Loading(origin = StoreReadResponseOrigin.Fetcher()),
awaitItem()
awaitItem(),
)

assertEquals(
StoreReadResponse.Error.Custom(
error = customError,
origin = StoreReadResponseOrigin.Fetcher(),
),
awaitItem()
awaitItem(),
)
}
}
Expand Down
Loading

0 comments on commit 29db0a1

Please sign in to comment.