From 11e25014556f821dd91808e7662540584998a8d5 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sun, 16 Apr 2017 22:27:43 +0900 Subject: [PATCH] test server --- cmd/mstdn/cmd_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 cmd/mstdn/cmd_test.go diff --git a/cmd/mstdn/cmd_test.go b/cmd/mstdn/cmd_test.go new file mode 100644 index 0000000..1283922 --- /dev/null +++ b/cmd/mstdn/cmd_test.go @@ -0,0 +1,31 @@ +package main + +import ( + "bytes" + "net/http" + "net/http/httptest" + + "github.com/mattn/go-mastodon" + "github.com/urfave/cli" +) + +func testWithServer(h http.HandlerFunc, testFunc func(*cli.App)) string { + ts := httptest.NewServer(h) + defer ts.Close() + + client := mastodon.NewClient(&mastodon.Config{ + Server: ts.URL, + ClientID: "foo", + ClientSecret: "bar", + AccessToken: "zoo", + }) + + var buf bytes.Buffer + app := makeApp() + app.Writer = &buf + app.Metadata = map[string]interface{}{ + "client": client, + } + testFunc(app) + return buf.String() +}