add comment to integration test
This commit is contained in:
+15
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user