Add direct

Closes #102
This commit is contained in:
Yasuhiro Matsumoto 2019-06-22 01:44:24 +09:00
parent 3268207afe
commit 9b8a47c42b
No known key found for this signature in database
GPG key ID: 622DE34DC490584B
5 changed files with 125 additions and 3 deletions

View file

@ -370,6 +370,28 @@ func TestGetTimelinePublic(t *testing.T) {
}
}
func TestGetTimelineDirect(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, `[{"content": "direct"}, {"content": "status"}]`)
}))
defer ts.Close()
client := NewClient(&Config{Server: ts.URL})
tl, err := client.GetTimelineDirect(context.Background(), nil)
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 != "direct" {
t.Fatalf("want %q but %q", "foo", tl[0].Content)
}
if tl[1].Content != "status" {
t.Fatalf("want %q but %q", "bar", tl[1].Content)
}
}
func TestGetTimelineHashtag(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/api/v1/timelines/tag/zzz" {