|
|
@@ -196,6 +196,39 @@ func TestFeed(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func TestAuthor(t *testing.T) {
|
|
|
+ srv, _ := newTestServer(t, map[string]string{
|
|
|
+ "2026-01-01-anon.md": "# Anonymous\n",
|
|
|
+ "2026-01-02-signed.md": "---\nauthor: Claude & co\n---\n# Signed\n",
|
|
|
+ })
|
|
|
+ _, _, index := get(t, srv, "/")
|
|
|
+ if !strings.Contains(index, "</time> · by Claude & co</span>") {
|
|
|
+ t.Errorf("index: author missing or unescaped:\n%s", index)
|
|
|
+ }
|
|
|
+ if strings.Count(index, " · by ") != 1 {
|
|
|
+ t.Error("index: a post without an author should not show a byline")
|
|
|
+ }
|
|
|
+ _, _, post := get(t, srv, "/posts/signed")
|
|
|
+ if !strings.Contains(post, "</time> · by Claude & co</span>") {
|
|
|
+ t.Errorf("post page: author missing:\n%s", post)
|
|
|
+ }
|
|
|
+ if _, _, anon := get(t, srv, "/posts/anon"); strings.Contains(anon, " · by ") {
|
|
|
+ t.Error("post page: byline shown without an author")
|
|
|
+ }
|
|
|
+ _, _, feed := get(t, srv, "/feed.xml")
|
|
|
+ for _, want := range []string{
|
|
|
+ `xmlns:dc="http://purl.org/dc/elements/1.1/"`,
|
|
|
+ "<dc:creator>Claude & co</dc:creator>",
|
|
|
+ } {
|
|
|
+ if !strings.Contains(feed, want) {
|
|
|
+ t.Errorf("feed: missing %q in:\n%s", want, feed)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Count(feed, "<dc:creator>") != 1 {
|
|
|
+ t.Error("feed: dc:creator should be omitted when there is no author")
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func TestHeaderAndFooter(t *testing.T) {
|
|
|
srv, dir := newTestServer(t, sample)
|
|
|
for _, path := range []string{"/", "/posts/middle", "/about", "/nope"} {
|