Skip to content

test(hash): add unit tests for Hash, Hash determinism, and Md5Hex edg…#5469

Merged
kevwan merged 1 commit intozeromicro:masterfrom
amshithnair:test-hash-unit-tests
Mar 15, 2026
Merged

test(hash): add unit tests for Hash, Hash determinism, and Md5Hex edg…#5469
kevwan merged 1 commit intozeromicro:masterfrom
amshithnair:test-hash-unit-tests

Conversation

@amshithnair
Copy link
Contributor

Problem

The Hash() function in core/hash/hash.go (murmur3 wrapper) has no dedicated unit test. Only Md5() and Md5Hex() are directly tested. While Hash() is exercised indirectly through consistenthash_test.go, the function itself lacks isolated coverage.

Solution

Added 4 new test cases to core/hash/hash_test.go:

Test Purpose
TestHash Verifies Hash() returns a non-zero value for non-empty input
TestHash_Deterministic Verifies identical inputs always produce the same hash
TestHash_Empty Ensures Hash() does not panic on empty byte slice
TestMd5Hex_Empty Validates Md5Hex() returns a valid 32-char hex string for empty input

Impact

  • Test-only change — no production code modified
  • No public API changes
  • No breaking changes

Testing performed

go test -v -count=1 ./core/hash/...   # PASS
go vet ./core/hash/...                # PASS

Files changed

  • core/hash/hash_test.go — added 4 test functions

@kevwan kevwan force-pushed the test-hash-unit-tests branch from 5892f11 to 69521c8 Compare March 15, 2026 14:52
@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kevwan kevwan added this pull request to the merge queue Mar 15, 2026
Merged via the queue into zeromicro:master with commit 04ed637 Mar 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants