-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheventstore_test.go
53 lines (42 loc) · 1.2 KB
/
eventstore_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
package ehpg_test
import (
"context"
"github.com/go-redis/redis"
testsuite "github.com/looplab/eventhorizon/eventstore"
"github.com/looplab/eventhorizon/namespace"
rediseventstore "github.com/terraskye/eh-redis"
"testing"
)
func TestEventStore(t *testing.T) {
options := redis.UniversalOptions{
Addrs: []string{"127.0.0.1:6379"},
DB: 0,
OnConnect: nil,
Password: "",
}
db := redis.NewUniversalClient(&options)
defer db.Close()
store, err := rediseventstore.NewEventStore(db)
if err != nil {
t.Fatal("there should be no error")
}
if store == nil {
t.Fatal("there should be a store")
}
ctx := namespace.NewContext(context.Background(), "ns")
_ = store.Clear(context.Background())
defer func() {
t.Log("clearing db")
if err := store.Clear(context.Background()); err != nil {
t.Fatal("there should be no error:", err)
}
if err := store.Clear(ctx); err != nil {
t.Fatal("there should be no error:", err)
}
}()
// Run the actual test suite.
t.Log("event store with default namespace")
testsuite.AcceptanceTest(t, store, ctx)
t.Log("event store with other namespace")
testsuite.AcceptanceTest(t, store, namespace.NewContext(context.Background(), "other"))
}