forked from peterhellberg/hn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitems_test.go
54 lines (42 loc) · 1.24 KB
/
items_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
package hn
import (
"context"
"testing"
)
func TestItem_8863(t *testing.T) {
ts, c := testServerAndClientByFixture("8863")
defer ts.Close()
item, err := c.Item(context.Background(), 8863)
if err != nil {
t.Fatalf(`err != nil, got %v`, err)
}
if got, want := item.By, "dhouston"; got != want {
t.Fatalf(`item.By = %q, want %q`, got, want)
}
if got, want := item.Score, 111; got != want {
t.Fatalf(`item.Score = %d, want %d`, got, want)
}
if got, want := item.URL, "http://www.getdropbox.com/u/2/screencast.html"; got != want {
t.Fatalf(`item.URL = %q, want %q`, got, want)
}
}
func TestItem_8952(t *testing.T) {
ts, c := testServerAndClientByFixture("8952")
defer ts.Close()
item, err := c.Item(context.Background(), 8952)
if err != nil {
t.Fatalf(`err != nil, got %v`, err)
}
if got, want := item.By, "nickb"; got != want {
t.Fatalf(`item.By = %q, want %q`, got, want)
}
if got, want := item.Timestamp, 1175727286; got != want {
t.Fatalf(`item.Timestamp = %d, want %d`, got, want)
}
}
func TestItemTime(t *testing.T) {
item := Item{Timestamp: 1175727286}
if got, want := item.Time().UTC().Format("2006-01-02"), "2007-04-04"; got != want {
t.Fatalf(`item.Time().UTC().Format("2006-01-02") = %q, want %q`, got, want)
}
}