Files
pages/internal/server/feeds_capture_preview_test.go
T
Anya Tokugawa a5f90f933d
Build and publish container images / images (push) Successful in 11m2s
feat(feeds): add templated capture paths and inline modal
2026-11-08 13:44:20 +09:00

30 lines
876 B
Go

package server
import (
"encoding/json"
"strings"
"testing"
)
func TestFeedCapturePreview(t *testing.T) {
s, token, _, _, _ := feedFixture(t)
for _, tt := range []struct {
prefix string
status int
}{{"/notes/{YYYY}/{MM}/{DD}/{Subject}", 200}, {"/notes/{unknown}", 422}, {"/a/../b", 422}} {
w := feedRequestTest(s, token, "POST", "capture-preview", map[string]string{"prefix": tt.prefix, "title": "日本語 / test"})
if w.Code != tt.status {
t.Fatal(w.Code, w.Body)
}
if w.Code == 200 {
var data map[string]string
if e := json.Unmarshal(w.Body.Bytes(), &data); e != nil || strings.ContainsAny(data["prefix"], "{}") || !strings.HasSuffix(data["prefix"], "/日本語---test") {
t.Fatal(data, e)
}
}
}
if w := feedRequestTest(s, "", "POST", "capture-preview", map[string]string{"prefix": "/notes"}); w.Code != 401 {
t.Fatal(w.Code)
}
}