forked from couchbase/gocb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
token_test.go
50 lines (45 loc) · 1 KB
/
token_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
package gocb
import (
"encoding/json"
"gopkg.in/couchbase/gocbcore.v7"
"strings"
"testing"
)
func TestMutationState_Add(t *testing.T) {
fakeBucket := &Bucket{
name: "frank",
}
fakeToken1 := MutationToken{
token: gocbcore.MutationToken{
VbId: 1,
VbUuid: gocbcore.VbUuid(9),
SeqNo: gocbcore.SeqNo(12),
},
bucket: fakeBucket,
}
fakeToken2 := MutationToken{
token: gocbcore.MutationToken{
VbId: 2,
VbUuid: gocbcore.VbUuid(1),
SeqNo: gocbcore.SeqNo(22),
},
bucket: fakeBucket,
}
fakeToken3 := MutationToken{
token: gocbcore.MutationToken{
VbId: 2,
VbUuid: gocbcore.VbUuid(4),
SeqNo: gocbcore.SeqNo(99),
},
bucket: fakeBucket,
}
state := NewMutationState(fakeToken1, fakeToken2)
state.Add(fakeToken3)
bytes, err := json.Marshal(&state)
if err != nil {
t.Fatalf("Failed to marshal %v", err)
}
if strings.Compare(string(bytes), "{\"frank\":{\"1\":[12,\"9\"],\"2\":[99,\"4\"]}}") != 0 {
t.Fatalf("Failed to generate correct JSON output %s", bytes)
}
}