From af2ce2c3b177e9f7e502cea07ce45f2206f463d4 Mon Sep 17 00:00:00 2001 From: 178inaba <178inaba@users.noreply.github.com> Date: Sat, 15 Apr 2017 03:40:06 +0900 Subject: [PATCH] Add TestGetFavourites --- status_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 status_test.go diff --git a/status_test.go b/status_test.go new file mode 100644 index 0000000..4add3cd --- /dev/null +++ b/status_test.go @@ -0,0 +1,36 @@ +package mastodon + +import ( + "fmt" + "net/http" + "net/http/httptest" + "testing" +) + +func TestGetFavourites(t *testing.T) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintln(w, `[{"Content": "foo"}, {"Content": "bar"}]`) + return + })) + defer ts.Close() + + client := NewClient(&Config{ + Server: ts.URL, + ClientID: "foo", + ClientSecret: "bar", + AccessToken: "zoo", + }) + favs, err := client.GetFavourites() + if err != nil { + t.Fatalf("should not be fail: %v", err) + } + if len(favs) != 2 { + t.Fatalf("result should be two: %d", len(favs)) + } + if favs[0].Content != "foo" { + t.Fatalf("want %q but %q", "foo", favs[0].Content) + } + if favs[1].Content != "bar" { + t.Fatalf("want %q but %q", "bar", favs[1].Content) + } +}