Repository navigation
Add unit tests for modules/system package - #2134
Merged
Seanstoppable merged 7 commits intoJul 26, 2026
Merged
Seanstoppable merged 7 commits into
Seanstoppable merged 7 commits into
Conversation
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
force-pushed
the
seanstoppable-system-module-tests
branch
from
July 26, 2026 03:48
db6c1a5 to
00264fd
Compare
Seanstoppable
enabled auto-merge (squash)
July 26, 2026 03:51
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 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 titleNewWidget()— widget constructiondisplay()— rendered content formattingRefresh()— redraw channel signalingNot covered
panic(err)branch inNewSystemInfo(Windows variant) whenpowershell.exeitself fails to run — would require mockingexec.Command, out of scope for this pass.Validation
go test ./modules/system/... -v— all tests passgo vet ./modules/system/...— cleangolangci-lint run ./modules/system/...— clean (aside from pre-existing gofmt/CRLF noise unrelated to this change)