-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmightymap_badger_test.go
63 lines (49 loc) · 1.53 KB
/
mightymap_badger_test.go
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package mightymap_test
import (
"context"
"testing"
"time"
"github.com/thisisdevelopment/mightymap"
"github.com/thisisdevelopment/mightymap/storage"
)
var ctx = context.Background()
func TestMightyMap_BadgerStorage(t *testing.T) {
// Testing MightyMap with Badger storage implementation
store := storage.NewMightyMapBadgerStorage[int, string](
storage.WithMemoryStorage(true),
storage.WithDetectConflicts(false),
)
cm := mightymap.New[int, string](true, store)
// Repeat the same test cases as in TestMightyMap_DefaultStorage
t.Run("Store and Load", func(t *testing.T) {
cm.Store(ctx, 1, "one")
value, ok := cm.Load(ctx, 1)
if !ok || value != "one" {
t.Errorf("Expected to load 'one', got '%v'", value)
}
})
// Add other test cases...
}
func TestMightyMap_BadgerStorage_Encryption(t *testing.T) {
// Testing MightyMap with Badger storage implementation
store := storage.NewMightyMapBadgerStorage[int, string](
storage.WithMemoryStorage(true),
storage.WithDetectConflicts(false),
storage.WithEncryptionKey("test-key-123456789012345"),
storage.WithEncryptionKeyRotationDuration(10*24*time.Hour),
)
cm := mightymap.New[int, string](true, store)
// Repeat the same test cases as in TestMightyMap_DefaultStorage
t.Run("Store and Load", func(t *testing.T) {
cm.Store(ctx, 1, "one")
value, ok := cm.Load(ctx, 1)
if !ok || value != "one" {
t.Errorf("Expected to load 'one', got '%v'", value)
}
})
err := cm.Close(ctx)
if err != nil {
t.Errorf("Error closing map: %v", err)
}
// Add other test cases...
}