From aba9441cab9641192b1665d3579ecfe07b014c7c Mon Sep 17 00:00:00 2001 From: Umputun Date: Mon, 19 Feb 2018 00:53:14 -0600 Subject: [PATCH] add preview rest test --- app/rest/api/rest_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/rest/api/rest_test.go b/app/rest/api/rest_test.go index c04b05c3..87b0919f 100644 --- a/app/rest/api/rest_test.go +++ b/app/rest/api/rest_test.go @@ -56,6 +56,19 @@ func TestServer_Create(t *testing.T) { assert.True(t, len(c["id"].(string)) > 8) } +func TestServer_Preview(t *testing.T) { + srv, port := prep(t) + require.NotNil(t, srv) + defer cleanup(srv) + + r := strings.NewReader(`{"text": "test 123", "locator":{"url": "https://radio-t.com/blah1", "site": "radio-t"}}`) + resp, err := http.Post(fmt.Sprintf("http://127.0.0.1:%d/api/v1/preview", port), "application/json", r) + assert.Equal(t, http.StatusOK, resp.StatusCode) + b, err := ioutil.ReadAll(resp.Body) + assert.Nil(t, err) + assert.Equal(t, "

test 123

\n", string(b)) +} + func TestServer_CreateAndGet(t *testing.T) { srv, port := prep(t) assert.NotNil(t, srv)