From 60769b5cfc9753a63a55e0b8c9267d5f8c99e4cb Mon Sep 17 00:00:00 2001 From: Umputun Date: Tue, 22 May 2018 23:39:08 -0500 Subject: [PATCH] add comment to integration test --- app/main_test.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/main_test.go b/app/main_test.go index 75d3e6a9..287fb10b 100644 --- a/app/main_test.go +++ b/app/main_test.go @@ -7,6 +7,7 @@ import ( "log" "net/http" "os" + "strings" "syscall" "testing" "time" @@ -21,14 +22,22 @@ func TestApplication(t *testing.T) { go app.Run(ctx) time.Sleep(100 * time.Millisecond) // let server start + // send ping resp, err := http.Get("http://localhost:18080/api/v1/ping") require.Nil(t, err) defer resp.Body.Close() - assert.Equal(t, 200, resp.StatusCode) body, err := ioutil.ReadAll(resp.Body) assert.Nil(t, err) assert.Equal(t, "pong", string(body)) + + // add comment + resp, err = http.Post("http://dev:password@localhost:18080/api/v1/comment", "json", + strings.NewReader(`{"text": "test 123", "locator":{"url": "https://radio-t.com/blah1", "site": "remark"}}`)) + require.Nil(t, err) + assert.Equal(t, http.StatusCreated, resp.StatusCode) + body, _ = ioutil.ReadAll(resp.Body) + t.Log(string(body)) app.Wait() } @@ -55,12 +64,16 @@ func prepApp(t *testing.T, port int, duration time.Duration) (*Application, cont // prepare options opts := Opts{} p := flags.NewParser(&opts, flags.Default) - p.ParseArgs([]string{"--secret=123456"}) + p.ParseArgs([]string{"--secret=123456", "--dev-passwd=password"}) opts.AvatarStore, opts.BackupLocation = "/tmp", "/tmp" opts.BoltPath = fmt.Sprintf("/tmp/%d", port) opts.GithubCSEC, opts.GithubCID = "csec", "cid" + opts.GoogleCSEC, opts.GoogleCID = "csec", "cid" + opts.FacebookCSEC, opts.FacebookCID = "csec", "cid" opts.Port = port + os.Remove(opts.BoltPath + "/remark.db") + // create app app, err := New(opts) require.Nil(t, err)