POST /v1/feeds plain html
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"show-rss/src/cmd/server/handler"
|
||||
"show-rss/src/db"
|
||||
"show-rss/src/feeds"
|
||||
@@ -16,16 +17,17 @@ func TestFeeds(t *testing.T) {
|
||||
h := handler.New(ctx)
|
||||
|
||||
t.Run("happy", func(t *testing.T) {
|
||||
body := make(url.Values)
|
||||
body.Set("url", "url")
|
||||
body.Set("cron", "cron")
|
||||
body.Set("pattern", "pattern")
|
||||
body.Set("webhookMethod", "wmethod")
|
||||
body.Set("webhookURL", "wurl")
|
||||
body.Set("webhookBody", "wbody")
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest(http.MethodPost, "/v1/feeds", strings.NewReader(`{
|
||||
"url": "url",
|
||||
"cron": "cron",
|
||||
"pattern": "pattern",
|
||||
"webhookMethod": "wmethod",
|
||||
"webhookURL": "wurl",
|
||||
"webhookBody": "wbody"
|
||||
}`))
|
||||
r := httptest.NewRequest(http.MethodPost, "/v1/feeds", strings.NewReader(body.Encode()))
|
||||
r = r.WithContext(ctx)
|
||||
r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusOK {
|
||||
t.Errorf("(%d) %s", w.Code, w.Body.Bytes())
|
||||
|
||||
Reference in New Issue
Block a user