Repository navigation
Add unit tests for modules/textfile - #2132
Merged
Seanstoppable merged 1 commit intoJul 26, 2026
Merged
Seanstoppable merged 1 commit into
Seanstoppable merged 1 commit into
Conversation
Seanstoppable
force-pushed
the
seanstoppable-textfile-test-coverage
branch
from
July 24, 2026 14:28
adcec37 to
1939778
Compare
Adds table-driven tests covering settings parsing (defaults, format, formatStyle, wrapText, filePaths) and the read/parse/format pipeline in widget.go, using real temp files for plainText/formattedText/content. Covers empty files, missing files, multiple sources, format fallback for unknown lexer/style, and the full NewWidget lifecycle (keyboard controls, file watcher goroutine, Refresh, live file-change events). Coverage: 0% -> 85.2%.
Seanstoppable
force-pushed
the
seanstoppable-textfile-test-coverage
branch
from
July 26, 2026 03:39
1939778 to
587e386
Compare
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 unit test coverage for
modules/textfile, which previously had 0%.settings_test.go: table-driven tests forNewSettingsFromYAMLcovering defaults,format/formatStyle/wrapTextoverrides, andfilePathsvs. singlefilePath.widget_test.go: exercises the read/parse/format pipeline using real temp files (t.TempDir()):plainText()— normal/empty/multiline files, missing-file error pathformattedText()— valid lexer/style, unknown style fallback, unrecognized extension, empty file, missing-file error pathcontent()— plain vs. formatted mode, multi-source pagination, no-sources-configured edge caseNewWidget()full lifecycle — keyboard controls, file-watcher goroutine (including a live file-change event),Refresh(), with explicitStop()cleanupCoverage
0% → 85.2% of statements.
Remaining gaps are intentionally left uncovered:
openFile()shells out to the OS to launch an external program — not safe to trigger in tests.os.Exit(1)by design — would kill the test binary.nilfallback checks informattedText()for chroma's lexer/style/formatter lookups are effectively dead code, since those library functions never returnnilin practice.Testing
go test ./modules/textfile/... -v -cover— all passing, run multiple times for stability (goroutine/watcher lifecycle).