Add TestGetStatus

pull/15/head
178inaba 2017-04-16 17:11:47 +09:00
parent 39fd91e59f
commit 1495b1fb02
1 changed files with 30 additions and 0 deletions

View File

@ -35,6 +35,36 @@ func TestGetFavourites(t *testing.T) {
} }
} }
func TestGetStatus(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/api/v1/statuses/1234567" {
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
return
}
fmt.Fprintln(w, `{"Content": "zzz"}`)
return
}))
defer ts.Close()
client := NewClient(&Config{
Server: ts.URL,
ClientID: "foo",
ClientSecret: "bar",
AccessToken: "zoo",
})
_, err := client.GetStatus(123)
if err == nil {
t.Fatalf("should be fail: %v", err)
}
status, err := client.GetStatus(1234567)
if err != nil {
t.Fatalf("should not be fail: %v", err)
}
if status.Content != "zzz" {
t.Fatalf("want %q but %q", "zzz", status.Content)
}
}
func TestGetRebloggedBy(t *testing.T) { func TestGetRebloggedBy(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/api/v1/statuses/1234567/reblogged_by" { if r.URL.Path != "/api/v1/statuses/1234567/reblogged_by" {