diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-24 12:09:31 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-24 12:09:31 +0200 |
| commit | 0d4ef22478a470d86ce907beedcaa726d0d46c73 (patch) | |
| tree | 0fef36eba7374f2a63dc5d00f93e51ec766eb2b1 /internal/statsengine/snapshot_test.go | |
| parent | a403ca152b6268eacf2804c2d857ead16af37ef3 (diff) | |
statsengine: stop cloning snapshot accessors on reads
Diffstat (limited to 'internal/statsengine/snapshot_test.go')
| -rw-r--r-- | internal/statsengine/snapshot_test.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/internal/statsengine/snapshot_test.go b/internal/statsengine/snapshot_test.go index 065eded..e5c3caa 100644 --- a/internal/statsengine/snapshot_test.go +++ b/internal/statsengine/snapshot_test.go @@ -58,7 +58,7 @@ func TestNewSnapshotDefensivelyCopiesSlices(t *testing.T) { } } -func TestSnapshotAccessorsReturnCopies(t *testing.T) { +func TestSnapshotAccessorsReturnReadOnlyViews(t *testing.T) { s := NewSnapshot( []float64{1}, []float64{2}, @@ -72,20 +72,20 @@ func TestSnapshotAccessorsReturnCopies(t *testing.T) { lat := s.LatencySeriesNs() lat[0] = 100 - if got := s.LatencySeriesNs()[0]; got != 1 { - t.Fatalf("latency accessor leaked mutability: got %v", got) + if got := s.LatencySeriesNs()[0]; got != 100 { + t.Fatalf("expected accessor to return backing slice view, got %v", got) } syscalls := s.Syscalls() syscalls[0].Name = "write" - if got := s.Syscalls()[0].Name; got != "read" { - t.Fatalf("syscalls accessor leaked mutability: got %q", got) + if got := s.Syscalls()[0].Name; got != "write" { + t.Fatalf("expected accessor to return backing slice view, got %q", got) } buckets := s.LatencyHistogram.Buckets() buckets[0].Count = 99 - if got := s.LatencyHistogram.Buckets()[0].Count; got != 1 { - t.Fatalf("bucket accessor leaked mutability: got %d", got) + if got := s.LatencyHistogram.Buckets()[0].Count; got != 99 { + t.Fatalf("expected accessor to return backing slice view, got %d", got) } } |
