pull/7/head
Yasuhiro Matsumoto 2017-04-14 17:47:15 +09:00
parent 73f943d2d3
commit f765667837
1 changed files with 36 additions and 12 deletions

View File

@ -140,18 +140,6 @@ func TestGetAccount(t *testing.T) {
Server: ts.URL, Server: ts.URL,
ClientID: "foo", ClientID: "foo",
ClientSecret: "bar", 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", AccessToken: "zoo",
}) })
a, err := client.GetAccount(1) a, err := client.GetAccount(1)
@ -166,3 +154,39 @@ func TestGetAccount(t *testing.T) {
t.Fatalf("want %q but %q", "zzz", a.Username) 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)
}
}