diff --git a/mastodon_test.go b/mastodon_test.go index e41e287..69e520e 100644 --- a/mastodon_test.go +++ b/mastodon_test.go @@ -140,18 +140,6 @@ func TestGetAccount(t *testing.T) { 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", }) a, err := client.GetAccount(1) @@ -166,3 +154,39 @@ func TestGetAccount(t *testing.T) { t.Fatalf("want %q but %q", "zzz", a.Username) } } + +func TestGetAccountFollowing(t *testing.T) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/api/v1/accounts/1234567/following" { + http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) + return + } + fmt.Fprintln(w, `[{"Username": "foo"}, {"Username": "bar"}]`) + return + })) + defer ts.Close() + + client := NewClient(&Config{ + Server: ts.URL, + ClientID: "foo", + ClientSecret: "bar", + AccessToken: "zoo", + }) + fl, err := client.GetAccountFollowing(123) + if err == nil { + t.Fatalf("should not be fail: %v", err) + } + fl, err = client.GetAccountFollowing(1234567) + if err != nil { + t.Fatalf("should not be fail: %v", err) + } + if len(fl) != 2 { + t.Fatalf("result should be two: %d", len(fl)) + } + if fl[0].Username != "foo" { + t.Fatalf("want %q but %q", "foo", fl[0].Username) + } + if fl[1].Username != "bar" { + t.Fatalf("want %q but %q", "bar", fl[0].Username) + } +}