Add TestGetStatus
parent
39fd91e59f
commit
1495b1fb02
|
@ -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) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/api/v1/statuses/1234567/reblogged_by" {
|
||||
|
|
Loading…
Reference in New Issue