pull/7/head
Yasuhiro Matsumoto 2017-04-14 17:26:22 +09:00
parent d168c8b4a6
commit c3ca0792f5
1 changed files with 40 additions and 0 deletions

View File

@ -76,6 +76,46 @@ func TestPostStatus(t *testing.T) {
} }
} }
func TestGetTimelineHome(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, `[{"Content": "foo"}, {"Content": "bar"}]`)
return
}))
defer ts.Close()
client := NewClient(&Config{
Server: ts.URL,
ClientID: "foo",
ClientSecret: "bar",
})
_, err := client.PostStatus(&Toot{
Status: "foobar",
})
if err == nil {
t.Fatalf("should be fail: %v", err)
}
client = NewClient(&Config{
Server: ts.URL,
ClientID: "foo",
ClientSecret: "bar",
AccessToken: "zoo",
})
tl, err := client.GetTimelineHome()
if err != nil {
t.Fatalf("should not be fail: %v", err)
}
if len(tl) != 2 {
t.Fatalf("result should be two: %d", len(tl))
}
if tl[0].Content != "foo" {
t.Fatalf("want %q but %q", "foo", tl[0].Content)
}
if tl[1].Content != "bar" {
t.Fatalf("want %q but %q", "bar", tl[0].Content)
}
}
func TestForTheCoverages(t *testing.T) { func TestForTheCoverages(t *testing.T) {
(*UpdateEvent)(nil).event() (*UpdateEvent)(nil).event()
(*NotificationEvent)(nil).event() (*NotificationEvent)(nil).event()