mirror of
https://github.com/grafana/loki.git
synced 2026-03-13 09:33:58 +08:00
26 lines
431 B
Go
26 lines
431 B
Go
package memory
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestAllocator_lock(t *testing.T) {
|
|
var alloc Allocator
|
|
|
|
t.Run("can lock and unlock without panic", func(t *testing.T) {
|
|
require.NotPanics(t, func() {
|
|
alloc.lock()
|
|
alloc.unlock()
|
|
})
|
|
})
|
|
|
|
t.Run("cannot double-lock", func(t *testing.T) {
|
|
require.PanicsWithValue(t, errConcurrentUse, func() {
|
|
alloc.lock()
|
|
alloc.lock()
|
|
})
|
|
})
|
|
}
|