Skip to content

Add unit tests for modules/bargraph (0% → 100% coverage) - #2144

Merged
Seanstoppable merged 1 commit into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-bargraph-test-coverage
Jul 26, 2026
Merged

Seanstoppable merged 1 commit into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-bargraph-test-coverage

Conversation

@Seanstoppable

Copy link
Copy Markdown
Collaborator

Summary

Adds table-driven unit tests for modules/bargraph, bringing statement coverage from 0% to 100%.

Tests Added

  • TestNewSettingsFromYAML — verifies settings construction with default and custom titles
  • TestDefaultConstants — asserts default focusable/title values
  • TestNewWidget — validates widget construction
  • TestMakeGraph — checks output format (8 bars, time labels)
  • TestMakeGraph_BarsHaveValidFormat — verifies bar characters and color markers
  • TestMakeGraph_MultipleCallsOverwrite — ensures repeated calls produce valid output
  • TestRefresh — exercises the enabled refresh path
  • TestRefresh_WhenDisabled — exercises the disabled early-return path
  • TestBuildStars_* — comprehensive tests for the pure view.BuildStars function:
    • Empty data, single bar, custom value labels, default color fallback, label alignment, 0%/100% edge cases, and a parametric table-driven suite

Verification

$ go test ./modules/bargraph/ -cover
ok  	github.com/wtfutil/wtf/modules/bargraph	coverage: 100.0% of statements

Table-driven tests covering:
- NewSettingsFromYAML with default and custom values
- NewWidget construction
- MakeGraph output format and bar count
- Refresh when enabled and disabled
- BuildStars with various percentages, labels, alignment, and edge cases
@Seanstoppable
Seanstoppable force-pushed the seanstoppable-bargraph-test-coverage branch from 34d4e65 to dc39b24 Compare July 26, 2026 04:39
@Seanstoppable
Seanstoppable enabled auto-merge (squash) July 26, 2026 04:41
@Seanstoppable
Seanstoppable merged commit bb838c1 into wtfutil:trunk Jul 26, 2026
3 checks passed
@Seanstoppable
Seanstoppable deleted the seanstoppable-bargraph-test-coverage branch July 26, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 换网址