package main import ( "strings" "testing" ) func TestJoinURL(t *testing.T) { got := joinURL("https://example.com/", "/blog/", "post.html") if got != "https://example.com/blog/post.html" { t.Fatalf("unexpected URL: %s", got) } } func TestRSSDate(t *testing.T) { got, err := rssDate("2026-07-31") if err != nil { t.Fatal(err) } if got != "Fri, 31 Jul 2026 00:00:00 +0000" { t.Fatalf("unexpected RSS date: %s", got) } if _, err := rssDate("July 31"); err == nil { t.Fatal("expected invalid date to return an error") } } func TestMarkdownTitle(t *testing.T) { if got := markdownTitle("## A post title\n\nBody"); got != "A post title" { t.Fatalf("unexpected title: %s", got) } } func TestAddRSSDiscovery(t *testing.T) { oldConfig := config config = Config{Title: "Example & Blog", AbsoluteUrl: "https://example.com", RelativePath: "/notes"} defer func() { config = oldConfig }() got := addRSSDiscovery("") if !strings.Contains(got, `rel="alternate"`) || !strings.Contains(got, `href="https://example.com/notes/rss.xml"`) { t.Fatalf("RSS discovery link missing: %s", got) } if !strings.Contains(got, `title="Example & Blog RSS"`) { t.Fatalf("RSS title was not escaped: %s", got) } }