Add TestGetTimelineMedia
parent
8bb0a0f85f
commit
47292cbca3
|
@ -393,6 +393,42 @@ func TestGetTimelineHashtag(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGetTimelineMedia(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Query().Get("local") == "" {
|
||||
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
fmt.Fprintln(w, `[{"content": "zzz"},{"content": "yyy"}]`)
|
||||
return
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
client := NewClient(&Config{
|
||||
Server: ts.URL,
|
||||
ClientID: "foo",
|
||||
ClientSecret: "bar",
|
||||
AccessToken: "zoo",
|
||||
})
|
||||
_, err := client.GetTimelineMedia(context.Background(), false)
|
||||
if err == nil {
|
||||
t.Fatalf("should be fail: %v", err)
|
||||
}
|
||||
tags, err := client.GetTimelineMedia(context.Background(), true)
|
||||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
if len(tags) != 2 {
|
||||
t.Fatalf("should have %q entries but %q", "2", len(tags))
|
||||
}
|
||||
if tags[0].Content != "zzz" {
|
||||
t.Fatalf("want %q but %q", "zzz", tags[0].Content)
|
||||
}
|
||||
if tags[1].Content != "yyy" {
|
||||
t.Fatalf("want %q but %q", "zzz", tags[1].Content)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeleteStatus(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/api/v1/statuses/1234567" {
|
||||
|
|
Loading…
Reference in New Issue