pilorama/tests: Remove magic constants for inmemory type

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-01-31 18:43:43 +03:00
parent c916a75948
commit e4344fd5cc

View file

@ -18,11 +18,13 @@ import (
"golang.org/x/sync/errgroup"
)
const inmemoryType = "inmemory"
var providers = []struct {
name string
construct func(t testing.TB, opts ...Option) ForestStorage
}{
{"inmemory", func(t testing.TB, _ ...Option) ForestStorage {
{inmemoryType, func(t testing.TB, _ ...Option) ForestStorage {
f := NewMemoryForest()
require.NoError(t, f.Open(context.Background(), false))
require.NoError(t, f.Init())
@ -469,7 +471,7 @@ func testForestTreeApply(t *testing.T, constructor func(t testing.TB, _ ...Optio
func TestForest_ApplySameOperation(t *testing.T) {
for i := range providers {
t.Run(providers[i].name, func(t *testing.T) {
parallel := providers[i].name != "inmemory"
parallel := providers[i].name != inmemoryType
testForestApplySameOperation(t, providers[i].construct, parallel)
})
}
@ -763,7 +765,7 @@ func TestForest_ApplyRandom(t *testing.T) {
func TestForest_ParallelApply(t *testing.T) {
for i := range providers {
if providers[i].name == "inmemory" {
if providers[i].name == inmemoryType {
continue
}
t.Run(providers[i].name, func(t *testing.T) {
@ -922,7 +924,7 @@ var batchSizes = []int{1, 2, 4, 8, 16, 32}
func BenchmarkApplySequential(b *testing.B) {
for i := range providers {
if providers[i].name == "inmemory" { // memory backend is not thread-safe
if providers[i].name == inmemoryType { // memory backend is not thread-safe
continue
}
b.Run(providers[i].name, func(b *testing.B) {
@ -958,7 +960,7 @@ func BenchmarkApplyReorderLast(b *testing.B) {
const blockSize = 10
for i := range providers {
if providers[i].name == "inmemory" { // memory backend is not thread-safe
if providers[i].name == inmemoryType { // memory backend is not thread-safe
continue
}
b.Run(providers[i].name, func(b *testing.B) {