From bb7a3a2892a015273686f65f31be28fbc2484fa6 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 21 Apr 2017 00:57:28 +0900 Subject: [PATCH] add test for stream --simplejson --- cmd/mstdn/cmd_stream_test.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cmd/mstdn/cmd_stream_test.go b/cmd/mstdn/cmd_stream_test.go index fdb3427..92c339b 100644 --- a/cmd/mstdn/cmd_stream_test.go +++ b/cmd/mstdn/cmd_stream_test.go @@ -52,18 +52,30 @@ data: {"content": "bar", "account":{"acct":"BAR"}} "config": config, } - go func() { + stop := func() { time.Sleep(5 * time.Second) if sig, ok := app.Metadata["signal"]; ok { sig.(chan os.Signal) <- os.Interrupt return } panic("timeout") - }() + } + var out string + + go stop() app.Run([]string{"mstdn", "stream"}) + out = buf.String() + if !strings.Contains(out, "FOO@") { + t.Fatalf("%q should be contained in output of command: %v", "FOO@", out) + } + if !strings.Contains(out, "foo") { + t.Fatalf("%q should be contained in output of command: %v", "foo", out) + } - out := buf.String() + go stop() + app.Run([]string{"mstdn", "stream", "--simplejson"}) + out = buf.String() if !strings.Contains(out, "FOO@") { t.Fatalf("%q should be contained in output of command: %v", "FOO@", out) }