mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-07-21 08:15:23 -04:00
[PR #153] [MERGED] test: add unit tests for perplexity and google search tools #195
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/153
Author: @mason5052
Created: 2/27/2026
Status: ✅ Merged
Merged: 3/2/2026
Merged by: @asdek
Base:
feature/next_release← Head:test/add-search-tool-coverage📝 Commits (3)
ddd0b0etest: add unit tests for perplexity and google search toolsc538b80test: address review feedback on search tool tests61a34c2fix: use context.Background() instead of t.Context() for consistency📊 Changes
2 files changed (+521 additions, -0 deletions)
View changed files
➕
backend/pkg/tools/google_test.go(+172 -0)➕
backend/pkg/tools/perplexity_test.go(+349 -0)📄 Description
Description
Problem
The
perplexity.goandgoogle.gosearch tools had zero test coverage. This makes it harder to catch regressions and verify behavior during refactoring.Solution
Add comprehensive unit tests for both tools, following the same patterns established in
tavily_test.goandtraversaal_test.go(from PR #151).perplexity_test.go(10 test functions, 20 sub-tests):TestPerplexityIsAvailable: API key presence checkTestPerplexityNewDefaults: verifies default model, temperature, topP, maxTokens, timeoutTestPerplexityNewCustomValues: verifies custom parameter passthroughTestPerplexityHandleErrorResponse: all 10 HTTP status codes (400-504) + unknown code (418)TestPerplexityFormatResponse: empty choices, with/without citations, nil/empty citations pointerTestPerplexityGetSummarizePrompt: template rendering with and without citationsTestPerplexitySearchHTTPErrors: verifies error propagation when endpoint is unreachableTestPerplexitySearchCreatesNewClientWithProxy: verifies proxy client creation without panicgoogle_test.go(4 test functions, 8 sub-tests):TestGoogleIsAvailable: requires bothapiKeyandcxKeyTestGoogleParseSearchResult: empty, single, multiple results, special characters preservedTestGoogleNewSearchServiceWithoutProxy: service creation succeedsTestGoogleNewSearchServiceWithProxy: service creation succeeds with proxy configuredType of Change
Areas Affected
Testing
Configuration
go test ./pkg/tools/ -run "TestPerplexity|TestGoogle" -v -count=1Test Results
All 24 tests pass:
Security Considerations
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.