-
Notifications
You must be signed in to change notification settings - Fork 0
/
kv_test.go
48 lines (41 loc) · 1.09 KB
/
kv_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
package main_test
import (
"context"
"testing"
redimo "github.com/dbProjectRED/redimo"
v1 "github.com/dbProjectRED/redimo/v1"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/stretchr/testify/assert"
)
func TestRedimoServiceGetAndSet(t *testing.T) {
service := redimo.RedimoService{}
table := makeTable()
value, _ := ptypes.MarshalAny(&wrappers.StringValue{Value: "v1"})
_, err := service.Set(context.Background(), &v1.SetRequest{
Table: &table,
Key: "k1",
Value: value,
})
assert.NoError(t, err)
resp, err := service.Get(context.Background(), &v1.GetRequest{
Table: &table,
Key: "k1",
})
assert.NoError(t, err)
assert.True(t, resp.Found)
sv := wrappers.StringValue{}
assert.NoError(t, ptypes.UnmarshalAny(resp.Value, &sv))
assert.Equal(t, "v1", sv.Value)
_, err = service.Del(context.Background(), &v1.DelRequest{
Table: &table,
Key: "k1",
})
assert.NoError(t, err)
resp, err = service.Get(context.Background(), &v1.GetRequest{
Table: &table,
Key: "k1",
})
assert.NoError(t, err)
assert.False(t, resp.Found)
}