-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathlive_test.go
108 lines (87 loc) · 1.9 KB
/
live_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
package replication
import (
"context"
"os"
"testing"
)
func liveOnly(t testing.TB) {
if os.Getenv("LIVE_TEST") != "true" {
t.Skipf("skipping live test, set LIVE_TEST=true to enable")
}
}
func TestCurrentState(t *testing.T) {
liveOnly(t)
ctx := context.Background()
_, _, err := CurrentMinuteState(ctx)
if err != nil {
t.Fatalf("request error: %v", err)
}
_, _, err = CurrentHourState(ctx)
if err != nil {
t.Fatalf("request error: %v", err)
}
_, _, err = CurrentDayState(ctx)
if err != nil {
t.Fatalf("request error: %v", err)
}
}
func TestDownloadChanges(t *testing.T) {
liveOnly(t)
ctx := context.Background()
_, err := Minute(ctx, 10)
if err != nil {
t.Fatalf("request error: %v", err)
}
_, err = Hour(ctx, 10)
if err != nil {
t.Fatalf("request error: %v", err)
}
_, err = Day(ctx, 1)
if err != nil {
t.Fatalf("request error: %v", err)
}
}
func TestCurrentChangesetState(t *testing.T) {
liveOnly(t)
ctx := context.Background()
_, _, err := CurrentChangesetState(ctx)
if err != nil {
t.Fatalf("request error: %v", err)
}
}
func TestChangesets(t *testing.T) {
liveOnly(t)
ctx := context.Background()
sets, err := Changesets(ctx, 100)
if err != nil {
t.Fatalf("request error: %v", err)
}
if l := len(sets); l != 12 {
t.Errorf("incorrect number of changesets: %v", l)
}
}
func TestChangesetState(t *testing.T) {
liveOnly(t)
ctx := context.Background()
state, err := ChangesetState(ctx, 5001990)
if err != nil {
t.Fatalf("request error: %v", err)
}
if state.SeqNum != 5001990 {
t.Errorf("incorrect state: %+v", state)
}
// current state
n, state, err := CurrentChangesetState(ctx)
if err != nil {
t.Fatalf("request error: %v", err)
}
changes, err := Changesets(ctx, n)
if err != nil {
t.Fatalf("request error: %v", err)
}
for _, c := range changes {
if c.CreatedAt.After(state.Timestamp) {
t.Errorf("data is after the state file?")
}
}
}