Repository navigation
Conversation
|
✅ OpenCodeReview: Review skipped: no items were selected. |
if statement tests in manifest_hash_test.goif statement tests in manifest_hash_test.go
|
Hi @wu21-web, thanks for the contribution and for taking the time to look into this! Your observation is technically correct — for a correctly implemented pure function, calling it twice with the same receiver will always return the same value, so the condition is always false. However, we'd like to keep these determinism checks as regression guards. They protect against future changes that might accidentally introduce non-determinism (e.g., iterating over a map without sorting keys, inadvertently using timestamps, etc.). The cost of keeping them is essentially zero, but they provide a safety net if the underlying implementation ever changes. These kinds of invariant tests are common in projects where correctness of hash/digest functions is critical — their value lies not in catching bugs today, but in catching regressions tomorrow. Thanks again for the thoughtful review of our test code! |
|
Thanks for the explaination @lizhengfeng101 . I think the author meant this maybe: a1 := New(baseArgs)
a2 := New(baseArgs)
if a1.runtimeConfigSHA256() != a2.runtimeConfigSHA256() {
t.Fatal("runtimeConfigSHA256 is not deterministic")
}and for L44-L46 it is the same idea |
|
changes.patch |
if statement tests in manifest_hash_test.go
Description
READ:
#520 (comment)
#520 (comment)
Type of Change
How Has This Been Tested?
make testpasses locallyChecklist
go fmt,go vet)Related Issues
none