-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounter_test.go
65 lines (51 loc) · 1.17 KB
/
counter_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
package rkive
import (
check "gopkg.in/check.v1"
"os"
"time"
)
func (s *riakSuite) TestCounter(c *check.C) {
travis := os.Getenv("TRAVIS")
werck := os.Getenv("WERCKER")
if travis != "" || werck != "" {
c.Skip(`The CI environment does not have "allow_mult" set to 'true'`)
}
startt := time.Now()
var ct *Counter
var err error
ct, err = s.cl.Bucket("testbucket").NewCounter("test-counter", 0)
if err != nil {
c.Fatal(err)
}
start := ct.Val()
err = ct.Add(5)
if err != nil {
c.Error(err)
}
if ct.Val() != start+5 {
c.Errorf("Expected value %d; got %d", start+5, ct.Val())
}
err = ct.Refresh()
if err != nil {
c.Error(err)
}
if ct.Val() != start+5 {
c.Errorf("Expected value %d; got %d", start+5, ct.Val())
}
nct, err := s.cl.Bucket("testbucket").GetCounter("test-counter")
if err != nil {
c.Fatal(err)
}
if nct.Val() != start+5 {
c.Errorf("Expected value %d; got %d", start+5, nct.Val())
}
err = ct.Destroy()
if err != nil {
c.Error(err)
}
nct, err = s.cl.Bucket("testbucket").GetCounter("test-counter")
if err != ErrNotFound {
c.Errorf("Expected ErrNotFound (%q); got %q", ErrNotFound, err)
}
s.runtime += time.Since(startt)
}