|
|
@@ -196,6 +196,42 @@ func TestFeed(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func TestAuthor(t *testing.T) {
|
|
|
+ srv, dir := newTestServer(t, map[string]string{
|
|
|
+ "2026-01-01-anon.md": "# Anonymous\n",
|
|
|
+ "2026-01-02-signed.md": "---\nauthor: Ann & co\n---\n# Signed\n",
|
|
|
+ })
|
|
|
+ check := func(defaultAuthor string) {
|
|
|
+ t.Helper()
|
|
|
+ _, _, index := get(t, srv, "/")
|
|
|
+ for _, want := range []string{"</time> · by Ann & co</span>", "</time> · by " + defaultAuthor + "</span>"} {
|
|
|
+ if !strings.Contains(index, want) {
|
|
|
+ t.Errorf("index: missing %q:\n%s", want, index)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if _, _, post := get(t, srv, "/posts/signed"); !strings.Contains(post, "</time> · by Ann & co</span>") {
|
|
|
+ t.Errorf("signed post: author missing:\n%s", post)
|
|
|
+ }
|
|
|
+ if _, _, anon := get(t, srv, "/posts/anon"); !strings.Contains(anon, "</time> · by "+defaultAuthor+"</span>") {
|
|
|
+ t.Errorf("anonymous post: want default author %q:\n%s", defaultAuthor, anon)
|
|
|
+ }
|
|
|
+ _, _, feed := get(t, srv, "/feed.xml")
|
|
|
+ for _, want := range []string{
|
|
|
+ `xmlns:dc="http://purl.org/dc/elements/1.1/"`,
|
|
|
+ "<dc:creator>Ann & co</dc:creator>",
|
|
|
+ "<dc:creator>" + defaultAuthor + "</dc:creator>",
|
|
|
+ } {
|
|
|
+ if !strings.Contains(feed, want) {
|
|
|
+ t.Errorf("feed: missing %q in:\n%s", want, feed)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ check("Claude")
|
|
|
+ writeFile(t, dir, "site.json", `{"defaultAuthor": "Site Owner"}`)
|
|
|
+ check("Site Owner")
|
|
|
+}
|
|
|
+
|
|
|
func TestHeaderAndFooter(t *testing.T) {
|
|
|
srv, dir := newTestServer(t, sample)
|
|
|
for _, path := range []string{"/", "/posts/middle", "/about", "/nope"} {
|