mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-08 01:16:45 +08:00
* test: remove implementation-only coverage Co-authored-by: multica-agent <[email protected]> * test: remove remaining implementation-only coverage Co-authored-by: multica-agent <[email protected]> * test: restore compatibility and fragment navigation coverage Co-authored-by: multica-agent <[email protected]> * test: preserve behavioral cleanup contracts Co-authored-by: multica-agent <[email protected]> --------- Co-authored-by: Sol-Boy <[email protected]> Co-authored-by: multica-agent <[email protected]>
29 lines
742 B
Go
29 lines
742 B
Go
package taskfailure
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// TestAllReasonsIsDefensiveCopy guards the contract that mutating the
|
|
// returned slice cannot corrupt the package-level fixture. Without
|
|
// this, two callers (e.g. two Prometheus collectors at startup) could
|
|
// race on a shared slice.
|
|
func TestAllReasonsIsDefensiveCopy(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
first := AllReasons()
|
|
if len(first) == 0 {
|
|
t.Fatal("AllReasons() returned empty slice")
|
|
}
|
|
original := first[0]
|
|
first[0] = "tampered"
|
|
|
|
second := AllReasons()
|
|
if second[0] == "tampered" {
|
|
t.Fatalf("AllReasons() leaked package state: second call returned tampered value %q", second[0])
|
|
}
|
|
if second[0] != original {
|
|
t.Fatalf("AllReasons()[0] = %q, want %q", second[0], original)
|
|
}
|
|
}
|