-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
query_consistency_test.go
163 lines (121 loc) · 3.54 KB
/
query_consistency_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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package goriak
import (
"testing"
)
func TestSetRawWithConsistancyOptions(t *testing.T) {
_, err := Bucket("raw", "default").
SetRaw([]byte("Hello Raw")).
WithPw(4).Run(con())
expectedError := "ClientError|[Cluster] all retries exhausted and/or no nodes available to execute command|InnerError|RiakError|0|{n_val_violation,3}"
if err.Error() != expectedError {
t.Error("Unexpected error PW:", err)
}
_, err = Bucket("raw", "default").
SetRaw([]byte("Hello Raw")).
WithDw(4).Run(con())
if err.Error() != expectedError {
t.Error("Unexpected error DW:", err)
}
_, err = Bucket("raw", "default").
SetRaw([]byte("Hello Raw")).
WithW(4).Run(con())
if err.Error() != expectedError {
t.Error("Unexpected error W:", err)
}
}
func TestGetWithConsistancyOptions(t *testing.T) {
input, err := Bucket("raw", "default").
SetRaw([]byte("Hello Raw")).
Run(con())
_, err = Bucket("raw", "default").
GetRaw(input.Key, &[]byte{}).
WithPr(4).Run(con())
expectedError := "ClientError|[Cluster] all retries exhausted and/or no nodes available to execute command|InnerError|RiakError|0|{n_val_violation,3}"
if err.Error() != expectedError {
t.Error("Unexpected error PW:", err)
}
_, err = Bucket("raw", "default").
GetRaw(input.Key, &[]byte{}).
WithR(4).Run(con())
if err.Error() != expectedError {
t.Error("Unexpected error PW:", err)
}
}
func TestSetWithConsistancyOptions(t *testing.T) {
val := struct {
A string
}{
A: "Hello A",
}
_, err := Bucket("testsuitemap", "maps").
Set(val).
WithPw(4).Run(con())
expectedError := "ClientError|[Cluster] all retries exhausted and/or no nodes available to execute command|InnerError|RiakError|0|{n_val_violation,3}"
if err.Error() != expectedError {
t.Error("Unexpected error PW:", err)
}
_, err = Bucket("testsuitemap", "maps").
Set(val).
WithDw(4).Run(con())
if err.Error() != expectedError {
t.Error("Unexpected error DW:", err)
}
_, err = Bucket("testsuitemap", "maps").
Set(val).
WithW(4).Run(con())
if err.Error() != expectedError {
t.Error("Unexpected error W:", err)
}
}
func TestDeleteWithConsistancyOptions(t *testing.T) {
c := con()
insert, err := Bucket("raw", "default").SetRaw([]byte("Hello Delete")).Run(c)
if err != nil {
t.Error(err)
}
expectedError := "ClientError|[Cluster] all retries exhausted and/or no nodes available to execute command|InnerError|RiakError|0|{n_val_violation,3}"
_, err = Bucket("raw", "default").Delete(insert.Key).WithDw(4).Run(c)
if err.Error() != expectedError {
t.Error(err)
}
_, err = Bucket("raw", "default").Delete(insert.Key).WithPw(4).Run(c)
if err.Error() != expectedError {
t.Error(err)
}
_, err = Bucket("raw", "default").Delete(insert.Key).WithPr(4).Run(c)
if err.Error() != expectedError {
t.Error(err)
}
_, err = Bucket("raw", "default").Delete(insert.Key).WithPw(4).Run(c)
if err.Error() != expectedError {
t.Error(err)
}
_, err = Bucket("raw", "default").Delete(insert.Key).WithR(4).Run(c)
if err.Error() != expectedError {
t.Error(err)
}
_, err = Bucket("raw", "default").Delete(insert.Key).WithW(4).Run(c)
if err.Error() != expectedError {
t.Error(err)
}
}
func TestUpdateHllWithConsistancyOptions(t *testing.T) {
_, err := Bucket("raw", "hlls").UpdateHyperLogLog().
Add([]byte{1}).
WithDw(5).
WithPw(5).
WithW(5).
Run(con())
if err == nil {
t.Error("no error")
}
}
func TestGetHllWithConsistancyOptions(t *testing.T) {
_, err := Bucket("raw", "hlls").GetHyperLogLog("123").
WithPr(5).
WithR(5).
Run(con())
if err == nil {
t.Error("no error")
}
}