test: add 21 unit tests for estimate_cost helpers#169
Open
TerminalGravity wants to merge 2 commits intomainfrom
Open
test: add 21 unit tests for estimate_cost helpers#169TerminalGravity wants to merge 2 commits intomainfrom
TerminalGravity wants to merge 2 commits intomainfrom
Conversation
…ton) Covers: - Default config when no .preflight/ dir - Singleton caching behavior - config.yml parsing and merging with defaults - triage.yml parsing - Graceful handling of invalid/empty YAML - Environment variable overrides (profile, related projects, embeddings) - Env vars ignored when .preflight/ dir exists - getRelatedProjects() backward compat helper - hasPreflightConfig() detection
- Export helper functions (estimateTokens, extractText, extractToolNames, formatTokens, formatCost, formatDuration, analyzeSessionFile) for testability - Add comprehensive tests covering token estimation, text extraction, tool name extraction, formatting, session analysis with corrections, tool calls, preflight detection, and timestamp tracking - First tool-level test file (tests/tools/)
TerminalGravity
commented
Mar 9, 2026
Collaborator
Author
TerminalGravity
left a comment
There was a problem hiding this comment.
21 tests for estimate_cost — good coverage. LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Exports helper functions from estimate-cost.ts and adds the first tool-level test file with 21 tests covering:
estimateTokens— token estimation from char countextractText— text extraction from string/content blocks/nullsextractToolNames— tool name extraction from content arraysformatTokens/formatCost/formatDuration— display formattinganalyzeSessionFile— full session analysis including corrections, tool calls, preflight detection, timestamps, and tool_result handlingTotal test count: 56 → 77