add support for pinned posts

This commit is contained in:
Rasmus Lindroth 2022-06-04 15:44:49 +02:00
parent 738ed0b9db
commit 01a4ad5a68
2 changed files with 50 additions and 0 deletions

View file

@ -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" {