Tests Phase 1: pure unit coverage + CI workflow#2
Merged
Conversation
First of three planned phases bringing this repo from a single layout
test to a real test suite. Phase 1 covers the L1 layer per the test plan:
pure functions, no I/O, no goroutines, no HTTP. Future phases add
httptest-mocked integration (Phase 2) and TUI flow tests (Phase 3).
Coverage by package:
config 90.6% (Load precedence, Dir/Path, error paths)
auth 27.6% (PKCE verifier/challenge incl. RFC 7636 vector,
buildAuthURL shape, TokenData.Valid boundaries,
token round-trip + corrupt-file recovery)
api 13.2% (SetRegion, navItemFromTypename, parseTime,
apiUser.fullName, sanitizeFilename — Phase 2 will
cover gqlQuery, GetHubs/Projects/etc. via httptest)
fusion 27.9% (NormalizeProjectID, validFileID security regression,
buildInsertScript JSON round-trip, parseToolErrorText,
extractSSEData SSE parsing, OpenDocument/InsertDocument
input validation tripwire — security regression for M2)
ui 24.5% (formatSize boundaries; existing layout_test retained)
total 23.9%
Three of these tests deliberately encode the security fixes from the
prior PR so a future refactor can't silently undo them:
- TestValidFileID rejects newlines, quotes, slashes, unicode (M2)
- TestOpenDocument_ValidatesInput uses a tripwire endpoint to prove
validation runs *before* dial (M2)
- TestBuildInsertScript_JSONEscaping round-trips the encoded value
through json.Unmarshal (M2)
CI: new .github/workflows/test.yml runs `go vet`, `go test -race
-count=1 -coverprofile`, and prints a coverage summary on every PR
and push to main. Makefile `check` target now matches CI by adding
`-race`.
All tests run in under 4s locally with the race detector on.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
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
First of three planned phases bringing this repo from a single layout test (
ui/layout_test.go) to a real test suite. Phase 1 covers the L1 layer per the test plan: pure functions, no I/O, no goroutines, no HTTP. Future phases add httptest-mocked integration (Phase 2) and TUI flow tests (Phase 3).Coverage by package
configLoadprecedence (env → file → ldflags),Dir/Path, error pathsauthbuildAuthURLshape,TokenData.Validboundaries, token round-trip + corrupt-file recoveryapiSetRegion,navItemFromTypename,parseTime,apiUser.fullName,sanitizeFilenamefusionNormalizeProjectID,validFileIDsecurity regression,buildInsertScriptJSON round-trip,parseToolErrorText,extractSSEData,OpenDocument/InsertDocumentinput validation tripwireuiformatSizeboundaries; existinglayout_test.goretainedauth/api/fusionsignificantly via httptest mocksSecurity regression coverage
Three Phase 1 tests deliberately encode the security fixes from the prior PR so a future refactor can't silently undo them:
TestValidFileIDrejects newlines, quotes, slashes, unicode (M2)TestOpenDocument_ValidatesInputuses a tripwire endpoint to prove validation runs before dial (M2)TestBuildInsertScript_JSONEscapinground-trips the encoded value throughjson.Unmarshal(M2)H1 and H2 regression tests live in Phase 2 since they need
httptest.Server.CI
New
.github/workflows/test.ymlrunsgo vet,go test -race -count=1 -coverprofile, and prints a coverage summary on every PR and push to main.Makefilechecktarget now matches CI by adding-race.All tests run in under 4s locally with the race detector on.
Test plan
make check(vet + race + tests) passes locallytest.ymlworkflow runs green on this PR🤖 Generated with Claude Code