forked from peterhellberg/hn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlive_test.go
52 lines (41 loc) · 1.1 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
package hn
import (
"testing"
"context"
)
func TestTopStories(t *testing.T) {
ts, c := testServerAndClientByFixture("topstories")
defer ts.Close()
top, err := c.TopStories(context.Background())
if err != nil {
t.Fatalf(`err != nil, got %v`, err)
}
if got, want := len(top), 100; got != want {
t.Fatalf(`len(top) = %d, want %d`, got, want)
}
}
func TestMaxItem(t *testing.T) {
ts, c := testServerAndClientByFixture("maxitem")
defer ts.Close()
item, err := c.MaxItem(context.Background())
if err != nil {
t.Fatalf(`err != nil, got %v`, err)
}
if got, want := item, 8424452; got != want {
t.Fatalf(`item = %d, want %d`, got, want)
}
}
func TestUpdates(t *testing.T) {
ts, c := testServerAndClientByFixture("updates")
defer ts.Close()
updates, err := c.Updates(context.Background())
if err != nil {
t.Fatalf(`err != nil, got %v`, err)
}
if got, want := updates.Profiles[5], "benologist"; got != want {
t.Fatalf(`updates.Profiles[5] = %q, want %q`, got, want)
}
if got, want := updates.Items[7], 8423650; got != want {
t.Fatalf(`updates.Items[7] = %d, want %d`, got, want)
}
}