test: rewrite unit tests with testify/goleak; coverage 100% (#10)#19
Merged
Conversation
Replace the internal-package smoke test with a comprehensive black-box suite. Every public method has a dedicated TestX with subtests covering happy path, missing/zero-value distinctions, and edge cases. Four concurrency tests exercise store-read contention, LoadOrStore idempotency, Range-during-writes, and Delete-during-Range — each stable over -count=10 runs under -race. Coverage rises from 36.1% to 100.0% of statements in syncmap.go. Test deps added to go.mod: testify v1.11.1 and goleak v1.3.0. goleak wired via a single TestMain hook (VerifyTestMain) — per-test VerifyNone calls were dropped because t.Parallel() siblings would detect each other's goroutines. The CI coverage gate is left at 35% in this commit and raised to 95% in a follow-up commit on the same branch so the threshold flip is bisectable.
The preceding commit lifted coverage of syncmap.go to 100%. Flip the CI gate in ci.yml from the interim 35% floor to the AxonOps 95% target, and remove the TODO(#11) comment block. The release workflow at release.yml already enforced 95% independently.
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
Replaces the fork's internal-package smoke test with a comprehensive external-package suite and raises the CI coverage gate to the AxonOps 95% target. Coverage on
syncmap.gojumps from 36.1% to 100.0%.Closes #10.
What's in this PR
Two commits, bisectable:
test: rewrite unit tests in external package with testify/goleak (#10)— replacessyncmap_smoke_test.gowithsyncmap_test.go, addstestify v1.11.1andgoleak v1.3.0togo.mod, createsgo.sum.ci: raise coverage threshold to 95% (#10)— flipsthreshold=35.0→95.0in.github/workflows/ci.yml, removes theTODO(#11)comment.Test structure
package syncmap_test(black-box).TestMainwiresgoleak.VerifyTestMain(m)as the single package-wide leak hook (per-testVerifyNone(t)was dropped becauset.Parallel()siblings would detect each other's goroutines).TestXfunctions, 33 subtests, 48 totalt.Parallel()calls.Load,Store,LoadOrStore,LoadAndDelete,Delete,Range,Len,Map,Keys,Items— each with happy path, missing-key, zero-value distinction, and edge cases.TestConcurrentWritersReaders— 16 writers × 8 readers × 1000 ops, writer-id bounds asserted on loaded values.TestLoadOrStoreContention— 100 goroutines, single key, exactly one "stored" winner (viaatomic.Int32).TestRangeDuringWrites— writers cycle through the whole keyspace concurrently withRange; subset invariant asserted persync.Mapcontract.TestDeleteDuringRange— deleter concurrent withRange; no panic; observed(k, v)pairs satisfyk == v.go test -race -count=10.Coverage — per method
Agent gates
!okin Load,!lin LoadAndDelete, both Range callback paths)TestConcurrentWritersReaders, whole-keyspace writer loop inTestRangeDuringWrites. Both applied.go mod tidy + diffwas the pre-commit dirty state, resolved on commit)Local validation
Test plan
testmatrix stable on both ubuntu-latest and macos-latest