blob: 8436f067f2d2c2b8f8f965905b82cbb289ff4151 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 | package storage_test
import (
	"os"
	"testing"
	"codeberg.org/gruf/go-store/v2/storage"
)
func TestBlockStorage(t *testing.T) {
	// Set test path, defer deleting it
	testPath := "blockstorage.test"
	t.Cleanup(func() {
		os.RemoveAll(testPath)
	})
	// Open new blockstorage instance
	st, err := storage.OpenBlock(testPath, nil)
	if err != nil {
		t.Fatalf("Failed opening storage: %v", err)
	}
	// Attempt multi open of same instance
	_, err = storage.OpenBlock(testPath, nil)
	if err == nil {
		t.Fatal("Successfully opened a locked storage instance")
	}
	// Run the storage tests
	testStorage(t, st)
	// Test reopen storage path
	st, err = storage.OpenBlock(testPath, nil)
	if err != nil {
		t.Fatalf("Failed opening storage: %v", err)
	}
	st.Close()
}
 |