Add unit tests for modules/uptimekuma (0% → 99% coverage) - #2162
Open
Seanstoppable wants to merge 1 commit into
Open
Add unit tests for modules/uptimekuma (0% → 99% coverage)#2162Seanstoppable wants to merge 1 commit into
Seanstoppable wants to merge 1 commit into
Conversation
- Table-driven tests for parseURL (valid URLs, edge cases, errors) - httptest-based tests for fetchStatusData and fetchHeartbeatData (success, non-200, invalid JSON, connection errors) - content() rendering tests: all-up, mixed statuses, incidents, unparsable dates, loading state, empty data, out-of-range status - Settings tests: NewSettingsFromYAML with/without URL - Full integration tests: NewWidget, Refresh with success/errors - Coverage: 0% -> 99.0%
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 the
modules/uptimekumapackage, bringing test coverage from 0% to 99.0%.Tests Added
widget_test.goTestParseURL— table-driven tests for URL parsing (valid URLs, edge cases, error paths)TestFetchStatusData_*— httptest-based tests for status page fetching (success, non-200, invalid JSON, connection errors)TestFetchHeartbeatData_*— httptest-based tests for heartbeat fetching (success, non-200, invalid JSON, connection errors)TestContent_*— display rendering tests (error state, loading, all-up, mixed statuses, incidents with valid/unparsable dates, empty data, out-of-range status values)TestNewWidget— widget constructionTestRefresh_FullIntegration_*— end-to-end Refresh tests (success, invalid URL, status fetch error, heartbeat fetch error)TestConfigText— verifies help text generationsettings_test.goTestNewSettingsFromYAML— settings construction with URLTestNewSettingsFromYAML_EmptyURL— settings with missing URLTestDefaultConstants— verifies default valueshelpers_test.gomakeTestCommon,makeTestWidget) for creating minimal widgetsApproach
net/http/httptestfor all HTTP mocking — no external dependencies needed