Skip to content

Commit b9a28c5

Browse files
committed
Update MockFragment Stats method
The changes include synchronizing access to the underlying map when calculating the Length stat in the MockFragment's Stats() method. This is to ensure thread safety while accessing shared resources.
1 parent 3be3eb2 commit b9a28c5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/testutil/mockfragment/mockfragment.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ func New() *MockFragment {
4444
}
4545

4646
func (f *MockFragment) Stats() storage.Stats {
47-
return storage.Stats{}
47+
f.Lock()
48+
defer f.Unlock()
49+
return storage.Stats{
50+
Length: len(f.m),
51+
}
4852
}
4953

5054
func (f *MockFragment) Name() string {

0 commit comments

Comments
 (0)