Skip to content

test: add coverage for terminal yes/no prompt parsing#49346

Merged
strawgate merged 3 commits intomainfrom
test-improve-terminal-prompt-25b5ec70d99a4fcb
Apr 1, 2026
Merged

test: add coverage for terminal yes/no prompt parsing#49346
strawgate merged 3 commits intomainfrom
test-improve-terminal-prompt-25b5ec70d99a4fcb

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Mar 9, 2026

Summary

  • Added libbeat/common/terminal/terminal_test.go.
  • Added coverage for ReadInput() newline trimming.
  • Added coverage for PromptYesNo() behavior for default answers, mixed-case yes, and whitespace-padded no.

User scenarios covered

  • When a user runs keystore commands that ask for confirmation (for example overwrite/create prompts in libbeat/cmd/keystore.go), pressing Enter now has explicit tests proving default handling.
  • When a user types yes in different capitalization, tests verify the command treats it as confirmation.
  • When a user types no with accidental surrounding spaces, tests verify the command still rejects as expected.

Why this matters

  • These tests protect interactive CLI confirmation behavior used by keystore workflows.
  • Regressions in answer parsing (default, case, trimming) would now fail tests instead of surfacing to users at runtime.

Tests run

  • go test ./libbeat/common/terminal -count=5 (pass)
  • go test ./libbeat/common/terminal -count=1 (pass)

Removed or merged tests

  • None.

What is this? | From workflow: Test Improver

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Mar 9, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Mar 9, 2026

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @github-actions[bot]? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@strawgate strawgate self-assigned this Mar 20, 2026
@strawgate strawgate marked this pull request as ready for review March 20, 2026 18:21
@strawgate strawgate requested a review from a team as a code owner March 20, 2026 18:21
@strawgate strawgate requested review from mauri870 and rdner March 20, 2026 18:21
@strawgate strawgate added backport-skip Skip notification from the automated backport with mergify skip-changelog labels Mar 20, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8dddfb58-8c3b-41ec-be3d-23f3cac6aa60

📥 Commits

Reviewing files that changed from the base of the PR and between d09baaf and 2c2cb48.

📒 Files selected for processing (1)
  • libbeat/common/terminal/terminal_test.go

📝 Walkthrough

Walkthrough

A new test file was added to libbeat/common/terminal/terminal_test.go containing unit tests for terminal input functions. The file includes a helper function that manages stdin redirection for testing purposes. Two test functions were introduced: TestReadInput validates the ReadInput() function's ability to read and return stdin input, and TestPromptYesNo uses table-driven test cases to verify PromptYesNo() behavior across various input scenarios including yes, no, default responses, mixed-case input, and whitespace handling.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-improve-terminal-prompt-25b5ec70d99a4fcb
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Apr 1, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Apr 1, 2026
@mauri870
Copy link
Copy Markdown
Member

mauri870 commented Apr 1, 2026

Tested with stress, tests are stable.

@strawgate strawgate merged commit 7257769 into main Apr 1, 2026
207 checks passed
@strawgate strawgate deleted the test-improve-terminal-prompt-25b5ec70d99a4fcb branch April 1, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-skip Skip notification from the automated backport with mergify skip-changelog Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants