Add TestGetFollowRequests

pull/9/head
178inaba 2017-04-15 04:08:43 +09:00
parent 280982f034
commit 920eb1ad5a
1 changed files with 28 additions and 0 deletions

View File

@ -104,3 +104,31 @@ func TestAccountUnfollow(t *testing.T) {
t.Fatalf("want %t but %t", false, rel.Following)
}
}
func TestGetFollowRequests(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, `[{"Username": "foo"}, {"Username": "bar"}]`)
return
}))
defer ts.Close()
client := NewClient(&Config{
Server: ts.URL,
ClientID: "foo",
ClientSecret: "bar",
AccessToken: "zoo",
})
fReqs, err := client.GetFollowRequests()
if err != nil {
t.Fatalf("should not be fail: %v", err)
}
if len(fReqs) != 2 {
t.Fatalf("result should be two: %d", len(fReqs))
}
if fReqs[0].Username != "foo" {
t.Fatalf("want %q but %q", "foo", fReqs[0].Username)
}
if fReqs[1].Username != "bar" {
t.Fatalf("want %q but %q", "bar", fReqs[0].Username)
}
}