POST /v1/feeds plain html

This commit is contained in:
Bel LaPointe
2025-04-28 22:15:58 -06:00
parent e4e5529887
commit 29cb008f38
2 changed files with 29 additions and 22 deletions

View File

@@ -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())