[PR #172] [MERGED] test: add unit tests for executor helpers and terminal utilities #214

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

📋 Pull Request Information

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

Base: feature/next_releaseHead: test/executor-terminal-unit-tests


📝 Commits (1)

  • df401c9 test: add unit tests for executor helpers and terminal utilities

📊 Changes

2 files changed (+295 additions, -0 deletions)

View changed files

backend/pkg/tools/executor_test.go (+193 -0)
backend/pkg/tools/terminal_test.go (+102 -0)

📄 Description

Description

Add unit tests for helper functions in two core modules:

  • backend/pkg/tools/executor.go - JSON argument processing and barrier function management
  • backend/pkg/tools/terminal.go - Terminal name generation and ANSI-formatted output

Type of Change

  • New tests (no production code changes)

Areas Affected

  • backend/pkg/tools/executor_test.go (new file)
  • backend/pkg/tools/terminal_test.go (new file)

Testing

All tests are self-contained, table-driven, and use t.Parallel().

executor_test.go (4 test functions):

  • TestGetMessage - extracts "message" field from JSON args; covers valid message, empty message, missing field, invalid JSON, empty object, unicode content
  • TestArgsToMarkdown - converts JSON args to markdown bullet list; verifies "message" key is skipped, handles single/multiple fields, invalid JSON errors, empty objects
  • TestIsBarrierFunction - checks barrier map membership for known barriers (done, ask_user) and non-barriers
  • TestGetBarrierToolNames - returns all registered barrier tool names, verifies count and contents

terminal_test.go (3 test functions):

  • TestPrimaryTerminalName - generates "pentagi-terminal-{flowID}" format for various flow IDs
  • TestFormatTerminalInput - ANSI yellow-colored terminal input with cwd prefix, verifies color codes and line endings
  • TestFormatTerminalSystemOutput - ANSI blue-colored system output, verifies color codes and content wrapping

Security Considerations

No security impact - test-only changes.

Checklist

  • My code follows the existing code style of this project
  • I have performed a self-review of my own code
  • New tests added for the changes
  • Tests follow project conventions (table-driven, t.Parallel(), same package)

🔄 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/172 **Author:** [@mason5052](https://github.com/mason5052) **Created:** 3/2/2026 **Status:** ✅ Merged **Merged:** 3/2/2026 **Merged by:** [@asdek](https://github.com/asdek) **Base:** `feature/next_release` ← **Head:** `test/executor-terminal-unit-tests` --- ### 📝 Commits (1) - [`df401c9`](https://github.com/vxcontrol/pentagi/commit/df401c96260e36052d8be1ec8a6b9939d84006cb) test: add unit tests for executor helpers and terminal utilities ### 📊 Changes **2 files changed** (+295 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `backend/pkg/tools/executor_test.go` (+193 -0) ➕ `backend/pkg/tools/terminal_test.go` (+102 -0) </details> ### 📄 Description ## Description Add unit tests for helper functions in two core modules: - `backend/pkg/tools/executor.go` - JSON argument processing and barrier function management - `backend/pkg/tools/terminal.go` - Terminal name generation and ANSI-formatted output ## Type of Change - [x] New tests (no production code changes) ## Areas Affected - `backend/pkg/tools/executor_test.go` (new file) - `backend/pkg/tools/terminal_test.go` (new file) ## Testing All tests are self-contained, table-driven, and use `t.Parallel()`. **executor_test.go (4 test functions):** - `TestGetMessage` - extracts "message" field from JSON args; covers valid message, empty message, missing field, invalid JSON, empty object, unicode content - `TestArgsToMarkdown` - converts JSON args to markdown bullet list; verifies "message" key is skipped, handles single/multiple fields, invalid JSON errors, empty objects - `TestIsBarrierFunction` - checks barrier map membership for known barriers (done, ask_user) and non-barriers - `TestGetBarrierToolNames` - returns all registered barrier tool names, verifies count and contents **terminal_test.go (3 test functions):** - `TestPrimaryTerminalName` - generates "pentagi-terminal-{flowID}" format for various flow IDs - `TestFormatTerminalInput` - ANSI yellow-colored terminal input with cwd prefix, verifies color codes and line endings - `TestFormatTerminalSystemOutput` - ANSI blue-colored system output, verifies color codes and content wrapping ## Security Considerations No security impact - test-only changes. ## Checklist - [x] My code follows the existing code style of this project - [x] I have performed a self-review of my own code - [x] New tests added for the changes - [x] Tests follow project conventions (table-driven, t.Parallel(), same package) --- <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:44 -04:00
yindo closed this issue 2026-06-06 22:09:44 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#214