tests: close files explicitly and replace tsp-tcp test init/panics with helpers #11
Labels
No labels
nagonag
nagonag/ignore
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
heiko/mailseal#11
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Test resource/setup handling is inconsistent:
normalize_test.goopens each fixture but never closes it.internal/tsp-tcp/tcp_test.goloads fixtures frominit, panics on errors, and defers file closes inside a loop. Failures occur before a test can report useful context, and all defers wait until the entire initializer returns.Checklist: #35 (avoid defers accumulating in loops), #48 (avoid panics for recoverable setup failures), #79 (close opened resources), #90 (use test helpers/Cleanup).
Proposed fix
t.Cleanupimmediately after eachos.Openin normalization tests, or useos.ReadFilewhere a streaming reader is not under test.*testing.T, uset.Helper,require.NoError, and return typed request/response fixtures.initfor test data.TestMainonly if shared setup is necessary.Acceptance criteria
Reviewed against
948b7a9onmaster(Go 1.26.2).Fixture setup no longer uses init/panic, and test file resources are closed explicitly.
Closing commit:
5afb95a236d8