Skip to content

test(adapter): add finalize_body helper + 4-corner truth-table tests#4

Merged
dogzzdogzz merged 1 commit into
dogzzdogzz:feat/slack-streaming-togglefrom
antigenius0910:pr1115-add-finalize-body-test
Jun 22, 2026
Merged

test(adapter): add finalize_body helper + 4-corner truth-table tests#4
dogzzdogzz merged 1 commit into
dogzzdogzz:feat/slack-streaming-togglefrom
antigenius0910:pr1115-add-finalize-body-test

Conversation

@antigenius0910

Copy link
Copy Markdown

Adds a unit test for the reset && !keep_full_text && answer_start > 0 branch at the end of stream_prompt_blocks — the inline if-else that re-prepends the session-reset notice when send-once trimming would otherwise drop it.

Background — this addresses item #3 from my follow-up review on PR openabdev/openab#1115: that branch is the kind of edge case (reset && !streaming && answer_start > 0) that's easy to break silently, and it had no dedicated test.

What changes

  • Extracts the 4-line inline branch in stream_prompt_blocks into a pure helper pub fn finalize_body(reset, keep_full_text, answer_start, body) -> String. No behavior change — same truth table, same call site, same conditions.
  • Adds 4 tests covering every corner of (reset, keep_full_text, answer_start > 0):
    • reset + send-once + tool ran → notice re-prepended (the case from review item docs(slack): note reply_to bypass + clarify no-native-stream comment #3)
    • reset + send-once + no tools → pass through (notice already in slice via answer_start == 0)
    • reset + keep_full_text → pass through (slice already contains notice)
    • no reset (both flag combos) → pass through (no notice to manage)

Verification

  • cargo build passes on top of 78fdee2
  • cargo test passes — all 4 new tests green, no existing tests broken

Why a PR-to-PR

Layering this on top of openabdev#1115 rather than opening against main so it ships with the feature it tests. Merge into feat/slack-streaming-toggle and it'll flow into openabdev#1115 automatically. Or pass entirely — the test gap is a nit, not a blocker.

Addresses howie group-review 'Important #3' from PR openabdev#1115: the inline reset
re-prepend branch at end of stream_prompt_blocks had no unit test.

Extracts the four-line if-else into a pure helper finalize_body() and adds
4 tests covering every corner of (reset, keep_full_text, answer_start > 0).
No behavior change — same truth table, just testable in isolation.

Refs openabdev#1115 (comment)
@dogzzdogzz dogzzdogzz merged commit 67ea868 into dogzzdogzz:feat/slack-streaming-toggle Jun 22, 2026
6 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants