package gemtext import ( "bytes" "net/url" "testing" ) func TestGemsubToAtom(t *testing.T) { tests := []struct { url string input string output string }{ { url: "gemini://sombodys.site/a/page", input: ` # This is a gemlog page ## with a subtitle after empty lines => ./first-post.gmi 2023-08-25 - This is my first post `[1:], output: ` gemini://sombodys.site/a/page This is a gemlog page with a subtitle after empty lines 2023-08-25T12:00:00Z ./first-post.gmi This is my first post 2023-08-25T12:00:00Z `[1:], }, } for _, test := range tests { t.Run(test.url, func(t *testing.T) { doc, err := Parse(bytes.NewBufferString(test.input)) if err != nil { t.Fatal(err) } loc, err := url.Parse(test.url) if err != nil { t.Fatal(err) } out := &bytes.Buffer{} if err := GmisubToAtom(doc, *loc, out); err != nil { t.Fatal(err) } if out.String() != test.output { t.Fatal("mismatched output") } }) } }