Add unit tests for modules/healthchecks (0% → 98.6% coverage) - #2167
Open
Seanstoppable wants to merge 2 commits into
Open
Add unit tests for modules/healthchecks (0% → 98.6% coverage)#2167Seanstoppable wants to merge 2 commits into
Seanstoppable wants to merge 2 commits into
Conversation
- Table-driven tests for makeURL, timeSincePing, contentFrom - httptest-based tests for getExistingChecks: success, tags, error codes, invalid JSON, connection errors - Tests for content() method: error display, nil checks, check counting - Full JSON field parsing verification
- Add tests for NewWidget, Refresh (disabled + active), Render - Add tests for NewSettingsFromYAML with various configs - Add test for ConfigText - Use buffered redrawChan and tview.Application for full widget tests - All functions at 100% except getExistingChecks defer (95%)
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
Adds comprehensive unit tests for
modules/healthchecks, bringing test coverage from 0% to 98.6%.Test Coverage
NewWidgetRefreshRendercontentcontentFromtimeSincePingmakeURLgetExistingChecksNewSettingsFromYAMLConfigTextinitializeKeyboardControlsThe remaining 1.4% is a
defer resp.Body.Close()statement ingetExistingChecks.What's tested
makeURL): with/without tags, invalid URLscontentFrom): all status color mappings (green/red/lightgray/yellow)getExistingChecks): usesnet/http/httptestto mock the Healthchecks.io APINewWidget,Refresh(disabled + active),RenderNewSettingsFromYAMLwith various configs,ConfigTextcontent): error display, nil checks, up/total counting in titleAll tests are table-driven where applicable.