-
Notifications
You must be signed in to change notification settings - Fork 0
/
store_test.go
64 lines (49 loc) · 1.38 KB
/
store_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
64
package template
import (
"context"
"testing"
"time"
"github.com/kvtools/valkeyrie"
"github.com/kvtools/valkeyrie/store"
"github.com/kvtools/valkeyrie/testsuite"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const testTimeout = 60 * time.Second
func TestRegister(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
defer cancel()
kv, err := valkeyrie.NewStore(ctx, StoreName, []string{"TODO"}, nil)
require.NoError(t, err)
assert.NotNil(t, kv)
assert.IsTypef(t, kv, new(Store), "Error registering and initializing the store")
}
func TestStore(t *testing.T) {
// TODO remove the skip
t.Skip("the real store implementation is required")
kv := makeStore(t)
lockKV := makeStore(t)
ttlKV := makeStore(t)
t.Cleanup(func() {
testsuite.RunCleanup(t, kv)
})
testsuite.RunCleanup(t, kv)
testsuite.RunTestCommon(t, kv)
testsuite.RunTestAtomic(t, kv)
testsuite.RunTestWatch(t, kv)
testsuite.RunTestLock(t, kv)
testsuite.RunTestLockTTL(t, kv, lockKV)
testsuite.RunTestTTL(t, kv, ttlKV)
}
func makeStore(t *testing.T) store.Store {
t.Helper()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
config := &Config{
Username: "example",
Password: "example",
}
kv, err := New(ctx, []string{"TODO"}, config)
require.NoErrorf(t, err, "cannot create store")
return kv
}