[PR #200] [MERGED] test: add unit tests for pkg/terminal package #230

Closed
opened 2026-06-06 22:09:48 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vxcontrol/pentagi/pull/200
Author: @mason5052
Created: 3/12/2026
Status: Merged
Merged: 3/20/2026
Merged by: @asdek

Base: feature/next_releaseHead: test/terminal-output-coverage


📝 Commits (2)

  • 06c8ce4 test: add unit tests for pkg/terminal package
  • 335541a Fix cancellation tests to verify context.Canceled exactly

📊 Changes

1 file changed (+180 additions, -0 deletions)

View changed files

backend/pkg/terminal/output_test.go (+180 -0)

📄 Description

Description of Change

Problem: The pkg/terminal package has no unit test coverage. This package provides terminal output formatting, markdown rendering, JSON printing, and interactive user prompts used by the CLI installer and testers.

Solution: Add 21 unit tests covering IsMarkdownContent detection (headers, code blocks, bold, links, lists, plain text), InteractivePromptContext (input reading, whitespace trimming, context cancellation), GetYesNoInputContext (yes/no variants, case insensitivity), PrintJSON (valid/invalid data), and RenderMarkdown/PrintResult output functions.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Security update
  • Test update
  • Documentation update
  • Configuration change

Areas Affected

  • Core Services (Frontend UI / Backend API)
  • AI Agents (Researcher / Developer / Executor)
  • Security Tools Integration
  • Memory System (Vector Store / Knowledge Base)
  • Monitoring Stack (Grafana / OpenTelemetry)
  • Analytics & Reporting
  • External Integrations (LLM Providers / Search Engines / Security APIs)
  • Documentation
  • Infrastructure / DevOps

Testing and Verification

Test Configuration

  • PentAGI Version: v1.2.0 (master)
  • Go Version: 1.24.1
  • Host OS: Windows 11

Test Steps

  1. Run go test ./pkg/terminal/... -v

Test Results

=== RUN   TestIsMarkdownContent_Headers
--- PASS: TestIsMarkdownContent_Headers (0.00s)
=== RUN   TestIsMarkdownContent_CodeBlocks
--- PASS: TestIsMarkdownContent_CodeBlocks (0.00s)
=== RUN   TestIsMarkdownContent_Bold
--- PASS: TestIsMarkdownContent_Bold (0.00s)
=== RUN   TestIsMarkdownContent_Links
--- PASS: TestIsMarkdownContent_Links (0.00s)
=== RUN   TestIsMarkdownContent_Lists
--- PASS: TestIsMarkdownContent_Lists (0.00s)
=== RUN   TestIsMarkdownContent_PlainText
--- PASS: TestIsMarkdownContent_PlainText (0.00s)
=== RUN   TestInteractivePromptContext_ReadsInput
--- PASS: TestInteractivePromptContext_ReadsInput (0.00s)
=== RUN   TestInteractivePromptContext_TrimsWhitespace
--- PASS: TestInteractivePromptContext_TrimsWhitespace (0.00s)
=== RUN   TestInteractivePromptContext_CancelledContext
--- PASS: TestInteractivePromptContext_CancelledContext (0.00s)
=== RUN   TestGetYesNoInputContext_Yes
--- PASS: TestGetYesNoInputContext_Yes (0.00s)
=== RUN   TestGetYesNoInputContext_No
--- PASS: TestGetYesNoInputContext_No (0.00s)
=== RUN   TestGetYesNoInputContext_CancelledContext
--- PASS: TestGetYesNoInputContext_CancelledContext (0.00s)
=== RUN   TestPrintJSON_ValidData
--- PASS: TestPrintJSON_ValidData (0.00s)
=== RUN   TestPrintJSON_InvalidData
--- PASS: TestPrintJSON_InvalidData (0.00s)
=== RUN   TestRenderMarkdown_Empty
--- PASS: TestRenderMarkdown_Empty (0.00s)
=== RUN   TestRenderMarkdown_ValidContent
--- PASS: TestRenderMarkdown_ValidContent (0.00s)
=== RUN   TestPrintResult_PlainText
--- PASS: TestPrintResult_PlainText (0.00s)
=== RUN   TestPrintResult_MarkdownContent
--- PASS: TestPrintResult_MarkdownContent (0.00s)
=== RUN   TestPrintResultWithKey
--- PASS: TestPrintResultWithKey (0.00s)
PASS
ok  	pentagi/pkg/terminal	2.423s

Checklist

  • Code follows project coding standards
  • Tests added for changes
  • All tests pass
  • go fmt and go vet run
  • Changes are backward compatible

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vxcontrol/pentagi/pull/200 **Author:** [@mason5052](https://github.com/mason5052) **Created:** 3/12/2026 **Status:** ✅ Merged **Merged:** 3/20/2026 **Merged by:** [@asdek](https://github.com/asdek) **Base:** `feature/next_release` ← **Head:** `test/terminal-output-coverage` --- ### 📝 Commits (2) - [`06c8ce4`](https://github.com/vxcontrol/pentagi/commit/06c8ce4e4c2b13f8d9cbdd4f5cc9c1afb4ce2e9d) test: add unit tests for pkg/terminal package - [`335541a`](https://github.com/vxcontrol/pentagi/commit/335541ae50166e14576062841327b3c44241a36f) Fix cancellation tests to verify context.Canceled exactly ### 📊 Changes **1 file changed** (+180 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `backend/pkg/terminal/output_test.go` (+180 -0) </details> ### 📄 Description ## Description of Change **Problem:** The `pkg/terminal` package has no unit test coverage. This package provides terminal output formatting, markdown rendering, JSON printing, and interactive user prompts used by the CLI installer and testers. **Solution:** Add 21 unit tests covering IsMarkdownContent detection (headers, code blocks, bold, links, lists, plain text), InteractivePromptContext (input reading, whitespace trimming, context cancellation), GetYesNoInputContext (yes/no variants, case insensitivity), PrintJSON (valid/invalid data), and RenderMarkdown/PrintResult output functions. ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Security update - [x] Test update - [ ] Documentation update - [ ] Configuration change ## Areas Affected - [x] Core Services (Frontend UI / Backend API) - [ ] AI Agents (Researcher / Developer / Executor) - [ ] Security Tools Integration - [ ] Memory System (Vector Store / Knowledge Base) - [ ] Monitoring Stack (Grafana / OpenTelemetry) - [ ] Analytics & Reporting - [ ] External Integrations (LLM Providers / Search Engines / Security APIs) - [ ] Documentation - [ ] Infrastructure / DevOps ## Testing and Verification ### Test Configuration - PentAGI Version: v1.2.0 (master) - Go Version: 1.24.1 - Host OS: Windows 11 ### Test Steps 1. Run `go test ./pkg/terminal/... -v` ### Test Results ``` === RUN TestIsMarkdownContent_Headers --- PASS: TestIsMarkdownContent_Headers (0.00s) === RUN TestIsMarkdownContent_CodeBlocks --- PASS: TestIsMarkdownContent_CodeBlocks (0.00s) === RUN TestIsMarkdownContent_Bold --- PASS: TestIsMarkdownContent_Bold (0.00s) === RUN TestIsMarkdownContent_Links --- PASS: TestIsMarkdownContent_Links (0.00s) === RUN TestIsMarkdownContent_Lists --- PASS: TestIsMarkdownContent_Lists (0.00s) === RUN TestIsMarkdownContent_PlainText --- PASS: TestIsMarkdownContent_PlainText (0.00s) === RUN TestInteractivePromptContext_ReadsInput --- PASS: TestInteractivePromptContext_ReadsInput (0.00s) === RUN TestInteractivePromptContext_TrimsWhitespace --- PASS: TestInteractivePromptContext_TrimsWhitespace (0.00s) === RUN TestInteractivePromptContext_CancelledContext --- PASS: TestInteractivePromptContext_CancelledContext (0.00s) === RUN TestGetYesNoInputContext_Yes --- PASS: TestGetYesNoInputContext_Yes (0.00s) === RUN TestGetYesNoInputContext_No --- PASS: TestGetYesNoInputContext_No (0.00s) === RUN TestGetYesNoInputContext_CancelledContext --- PASS: TestGetYesNoInputContext_CancelledContext (0.00s) === RUN TestPrintJSON_ValidData --- PASS: TestPrintJSON_ValidData (0.00s) === RUN TestPrintJSON_InvalidData --- PASS: TestPrintJSON_InvalidData (0.00s) === RUN TestRenderMarkdown_Empty --- PASS: TestRenderMarkdown_Empty (0.00s) === RUN TestRenderMarkdown_ValidContent --- PASS: TestRenderMarkdown_ValidContent (0.00s) === RUN TestPrintResult_PlainText --- PASS: TestPrintResult_PlainText (0.00s) === RUN TestPrintResult_MarkdownContent --- PASS: TestPrintResult_MarkdownContent (0.00s) === RUN TestPrintResultWithKey --- PASS: TestPrintResultWithKey (0.00s) PASS ok pentagi/pkg/terminal 2.423s ``` ## Checklist - [x] Code follows project coding standards - [x] Tests added for changes - [x] All tests pass - [x] `go fmt` and `go vet` run - [x] Changes are backward compatible --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-06 22:09:48 -04:00
yindo closed this issue 2026-06-06 22:09:48 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#230