* WIP adding pruner to kv store impl * pruner only keeps 20 most recent versions * ignore grafana-kv-data folder * extracts some stuff to pruner.go file. Adds tests. Adds kvBackendOptions. * update logging, comments, exports kvbackendoptions fields * update nooppruner ref * fixes field casing in test * fix test * linter fixes * remove comment * make KvStorageBackend private * Adds pruner key validation and tests. Fixes broken tests. * update error message when validating pruner key
36 lines
868 B
Go
36 lines
868 B
Go
package test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
badger "github.com/dgraph-io/badger/v4"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/grafana/grafana/pkg/storage/unified/resource"
|
|
)
|
|
|
|
func TestBadgerKVStorageBackend(t *testing.T) {
|
|
RunStorageBackendTest(t, func(ctx context.Context) resource.StorageBackend {
|
|
opts := badger.DefaultOptions("").WithInMemory(true).WithLogger(nil)
|
|
db, err := badger.Open(opts)
|
|
require.NoError(t, err)
|
|
t.Cleanup(func() {
|
|
_ = db.Close()
|
|
})
|
|
kvOpts := resource.KvBackendOptions{
|
|
KvStore: resource.NewBadgerKV(db),
|
|
}
|
|
backend, err := resource.NewKvStorageBackend(kvOpts)
|
|
require.NoError(t, err)
|
|
return backend
|
|
}, &TestOptions{
|
|
NSPrefix: "kvstorage-test",
|
|
SkipTests: map[string]bool{
|
|
// TODO: fix these tests and remove this skip
|
|
TestBlobSupport: true,
|
|
TestListModifiedSince: true,
|
|
},
|
|
})
|
|
}
|