add support for pinned posts
This commit is contained in:
parent
c6a292132e
commit
b2204e0d6a
2 changed files with 50 additions and 0 deletions
|
@ -144,6 +144,44 @@ func TestGetAccountStatuses(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGetAccountPinnedStatuses(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/api/v1/accounts/1234567/statuses" {
|
||||
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
pinned := r.URL.Query().Get("pinned")
|
||||
if pinned != "true" {
|
||||
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
fmt.Fprintln(w, `[{"content": "foo"}, {"content": "bar"}]`)
|
||||
return
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
client := NewClient(&Config{
|
||||
Server: ts.URL,
|
||||
ClientID: "foo",
|
||||
ClientSecret: "bar",
|
||||
AccessToken: "zoo",
|
||||
})
|
||||
_, err := client.GetAccountPinnedStatuses(context.Background(), "123")
|
||||
if err == nil {
|
||||
t.Fatalf("should be fail: %v", err)
|
||||
}
|
||||
ss, err := client.GetAccountPinnedStatuses(context.Background(), "1234567")
|
||||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
if ss[0].Content != "foo" {
|
||||
t.Fatalf("want %q but %q", "foo", ss[0].Content)
|
||||
}
|
||||
if ss[1].Content != "bar" {
|
||||
t.Fatalf("want %q but %q", "bar", ss[1].Content)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAccountFollowers(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/api/v1/accounts/1234567/followers" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue