Skip to content

Commit

Permalink
Merge pull request #227 from modelix/bugfix/MODELIX-528_fix_isEmpty
Browse files Browse the repository at this point in the history
fix(modelql): let isEmpty return true on empty inputs
  • Loading branch information
languitar authored Sep 4, 2023
2 parents 31a340e + df7a7a9 commit cc40e83
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class HtmlBuilderTest {
}
}
}
val expected = """<html><body><ul><li>null<ul><li>abc<ul><li>model1a<ul></ul></li><li>model1b<ul></ul></li></ul></li></ul></li></ul></body></html>"""
val expected = """<html><body><ul><li>null<ul><li>abc<ul><li>model1a</li><li>model1b</li></ul></li></ul></li></ul></body></html>"""
assertEquals(expected, actual)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import kotlinx.serialization.serializer

class IsEmptyStep() : AggregationStep<Any?, Boolean>() {
override suspend fun aggregate(input: StepFlow<Any?>): IStepOutput<Boolean> {
return input.take(1).map { false }.onEmpty { emit(false) }.single().asStepOutput(this)
return input.take(1).map { false }.onEmpty { emit(true) }.single().asStepOutput(this)
}

override fun aggregate(input: Sequence<IStepOutput<Any?>>): IStepOutput<Boolean> = input.none().asStepOutput(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ class ModelQLTest {
assertEquals("alternative", result)
}

@Test
fun testIsEmpty() = runTestWithTimeout {
val result: Boolean = remoteProductDatabaseQuery { db ->
db.products.filter { it.id.equalTo(-1) }.isEmpty()
}
assertTrue(result)
}

@Test
fun test2() = runTestWithTimeout {
val result: List<String> = remoteProductDatabaseQuery { db ->
Expand Down

0 comments on commit cc40e83

Please sign in to comment.