mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-07-20 23:57:11 -04:00
[PR #171] [MERGED] test: add unit tests for agent context and tool registry #212
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/vxcontrol/pentagi/pull/171
Author: @mason5052
Created: 3/2/2026
Status: ✅ Merged
Merged: 3/2/2026
Merged by: @asdek
Base:
feature/next_release← Head:test/context-registry-unit-tests📝 Commits (2)
8768ea3test: add unit tests for agent context management and tool registry2fd6949test: add t.Parallel() to copy-safety tests and bidirectional completeness📊 Changes
2 files changed (+283 additions, -0 deletions)
View changed files
➕
backend/pkg/tools/context_test.go(+108 -0)➕
backend/pkg/tools/registry_test.go(+175 -0)📄 Description
Description
Add unit tests for two core infrastructure modules in
backend/pkg/tools/:context.go- Agent context management (PutAgentContext/GetAgentContext)registry.go- Tool type mapping, registry definitions, and type filteringType of Change
Areas Affected
backend/pkg/tools/context_test.go(new file)backend/pkg/tools/registry_test.go(new file)Testing
All tests are self-contained, table-driven where appropriate, and use
t.Parallel().context_test.go (5 test functions):
TestGetAgentContextEmpty- empty context returns falseTestPutAgentContextFirst- first call sets both parent and current to same agentTestPutAgentContextChaining- second call promotes current to parent, sets new currentTestPutAgentContextTriple- triple chaining verifies parent tracks previous currentTestPutAgentContextIsolation- independent context trees do not interfereregistry_test.go (6 test functions):
TestToolTypeString- all 8 ToolType enum values map to correct string representationsTestGetToolType- known tool names map to correct types, unknown returns NoneToolTypeTestGetToolTypeMappingCompleteness- all mapped tools resolve to non-None typeTestGetToolTypeMappingCopySafety- GetToolTypeMapping returns a copy (mutation does not affect original)TestGetToolsByType- filters tools correctly by type, empty result for unused typesTestToolTypeMappingRegistryConsistency- every tool in type mapping exists in registry definitionsSecurity Considerations
No security impact - test-only changes.
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.