Skip to content

Commit 8e8a9eb

Browse files
bobbai00claude
andcommitted
test(execution-service): cover remaining SyncExecutionResource branch partials
Add two unit cases to close branch gaps in the extracted helpers: - sampleAndTruncateTuples: empty iterator with a positive count (the `!tupleIterator.hasNext` half of the guard). - buildOperatorExecutionSummary: a console ERROR whose message is non-empty but shorter than the title (the length-comparison false branch), so the title is kept. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e411b54 commit 8e8a9eb

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

amber/src/test/scala/org/apache/texera/web/resource/SyncExecutionResourceSpec.scala

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,17 @@ class SyncExecutionResourceSpec extends AnyFlatSpec with Matchers with PrivateMe
215215
truncated shouldBe Some(false)
216216
}
217217

218+
it should "report an empty table when the iterator is empty despite a positive count" in {
219+
// Exercises the `!tupleIterator.hasNext` half of the guard (count > 0, no rows).
220+
val (mode, rows, total, returned, truncated) =
221+
resource.sampleAndTruncateTuples(Iterator.empty, 5, 100000, 100000)
222+
mode shouldBe "table"
223+
rows shouldBe Some(List.empty[SampleRow])
224+
total shouldBe Some(0)
225+
returned shouldBe Some(0)
226+
truncated shouldBe Some(false)
227+
}
228+
218229
it should "return visualization mode for a single visualization tuple" in {
219230
val vizSchema = new Schema(List(new Attribute("html-content", AttributeType.STRING)))
220231
val vizTuple =
@@ -342,6 +353,27 @@ class SyncExecutionResourceSpec extends AnyFlatSpec with Matchers with PrivateMe
342353
summary.errorMessages.head.message shouldBe "a long descriptive title"
343354
}
344355

356+
it should "keep the ERROR title when the message is non-empty but shorter" in {
357+
// Exercises `message.nonEmpty` true AND `message.length > title.length` false.
358+
val logs =
359+
List(
360+
ConsoleMessageInfo(
361+
msgType = "ERROR",
362+
title = "a fairly long error title",
363+
message = "short"
364+
)
365+
)
366+
val summary = resource.buildOperatorExecutionSummary(
367+
opId = "op-5",
368+
state = "Failed",
369+
resultMode = "table",
370+
result = None,
371+
tuplesCount = None,
372+
consoleLogs = Some(logs)
373+
)
374+
summary.errorMessages.head.message shouldBe "a fairly long error title"
375+
}
376+
345377
it should "leave the result summary empty when no result was materialized" in {
346378
val summary = resource.buildOperatorExecutionSummary(
347379
opId = "op-3",

0 commit comments

Comments
 (0)