Skip to content

Add unit tests for modules/system package - #2134

Merged
Seanstoppable merged 7 commits into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-system-module-tests
Jul 26, 2026
Merged

Seanstoppable merged 7 commits into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-system-module-tests

Conversation

@Seanstoppable

Copy link
Copy Markdown
Collaborator

Summary

Adds table-driven unit tests for modules/system, which previously had 0% test coverage.

Coverage: 0% → 95.7%

What's tested

  • prettyDate() — timestamp parsing/formatting, including error cases (empty, malformed, wrong format)
  • NewSettingsFromYAML() — default vs. custom title
  • NewWidget() — widget construction
  • display() — rendered content formatting
  • Refresh() — redraw channel signaling

Not covered

  • The panic(err) branch in NewSystemInfo (Windows variant) when powershell.exe itself fails to run — would require mocking exec.Command, out of scope for this pass.

Validation

  • go test ./modules/system/... -v — all tests pass
  • go vet ./modules/system/... — clean
  • golangci-lint run ./modules/system/... — clean (aside from pre-existing gofmt/CRLF noise unrelated to this change)

Table-driven tests for prettyDate() (date parsing/formatting) and
NewSettingsFromYAML() (settings construction). Coverage: 0% -> 26.1%.
NewSystemInfo() and NewWidget()/display() are left untested as they
shell out to OS commands or require a live tview.Application.
Covers widget construction and rendering logic using a real
tview.Application and buffered redraw channel. Coverage: 26.1% -> 95.7%.
Use promoted Title field instead of selecting through embedded Common.
The system module (modules/system) existed but was never wired into
MakeWidget's switch, so 'type: system' in a config always failed with
'module type does not exist'. Add the case, sourcing build version/date
from debug.ReadBuildInfo() (same mechanism flags.go uses for --version),
converted to the format system.Widget expects.

Adds buildVersion()/buildDate() helpers plus tests covering the new
switch case and both helpers.
Table-driven tests for prettyDate() (date parsing/formatting) and
NewSettingsFromYAML() (settings construction). Coverage: 0% -> 26.1%.
NewSystemInfo() and NewWidget()/display() are left untested as they
shell out to OS commands or require a live tview.Application.
Covers widget construction and rendering logic using a real
tview.Application and buffered redraw channel. Coverage: 26.1% -> 95.7%.
Win32_OperatingSystem.version reports '10.0.<build>' for both Windows 10
and Windows 11 -- Windows 11 never bumped the major.minor version, only
the build number (>= 22000). NewSystemInfo previously just concatenated
major.minor, so it always displayed 'Windows 10.0' even on Windows 11.

Extract the parsing into windowsProductVersion() and use the build
number to distinguish Windows 10 from Windows 11, with table-driven
tests covering both, the 22000 boundary, and malformed input.
@Seanstoppable
Seanstoppable force-pushed the seanstoppable-system-module-tests branch from db6c1a5 to 00264fd Compare July 26, 2026 03:48
@Seanstoppable
Seanstoppable enabled auto-merge (squash) July 26, 2026 03:51
@Seanstoppable
Seanstoppable merged commit a205f00 into wtfutil:trunk Jul 26, 2026
4 checks passed
@Seanstoppable
Seanstoppable deleted the seanstoppable-system-module-tests branch July 26, 2026 03:58
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

⌂ 换网址