Add unit tests for all cryptocurrency sub-modules - #2163
Open
Seanstoppable wants to merge 1 commit into
Open
Conversation
Add comprehensive test coverage for: - modules/cryptocurrency/bittrex (29.5%) - modules/cryptocurrency/blockfolio (23.9%) - modules/cryptocurrency/cryptolive (50.0%) - modules/cryptocurrency/cryptolive/price (75.0%) - modules/cryptocurrency/cryptolive/toplist (70.8%) - modules/cryptocurrency/mempool (68.0%) Tests use net/http/httptest to mock crypto APIs and cover: - JSON response parsing and struct deserialization - HTTP request construction and URL formatting - Price formatting and display logic - Settings initialization from YAML config - Error handling (network errors, invalid JSON, API failures) - Table-driven test patterns throughout Also fixes bugs in source code discovered during testing: - cryptolive/price: Report API errors instead of showing zero prices - cryptolive/toplist: Remove os.Exit(1) on JSON decode error, report errors gracefully instead of crashing the entire application
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.
Summary
Add comprehensive test coverage for all 6 cryptocurrency sub-modules, which previously had 0% coverage.
Coverage Results
cryptolive/pricecryptolive/toplistmempoolcryptolivebittrexblockfolioTest Approach
net/http/httptestto mock crypto API responsesBug Fixes Discovered During Testing
os.Exit(1)on JSON decode error — report errors gracefully instead of crashing the entire applicationNotes
Remaining uncovered code is primarily tview widget lifecycle methods (
Refresh/display/content/NewWidget) that require a full terminal UI environment to instantiate.