From 97552fbe30cdd4549d73ae31c976e524160f5ce5 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sun, 16 Apr 2017 22:37:46 +0900 Subject: [PATCH] add test for toot --- cmd/mstdn/cmd_toot_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 cmd/mstdn/cmd_toot_test.go diff --git a/cmd/mstdn/cmd_toot_test.go b/cmd/mstdn/cmd_toot_test.go new file mode 100644 index 0000000..2f2f0d3 --- /dev/null +++ b/cmd/mstdn/cmd_toot_test.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "net/http" + "testing" + + "github.com/urfave/cli" +) + +func TestCmdToot(t *testing.T) { + toot := "" + testWithServer( + func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/api/v1/statuses" { + http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) + return + } + toot = r.FormValue("status") + fmt.Fprintln(w, `{"ID": 2345}`) + return + }, + func(app *cli.App) { + app.Run([]string{"mstdn", "toot", "foo"}) + }, + ) + if toot != "foo" { + t.Fatalf("want %q, got %q", "foo", toot) + } +}