package obsimport import "testing" func TestStripFrontMatter(t *testing.T) { tests := []struct { name string input string want string }{ { name: "no front matter", input: "Hello world\nThis is a note", want: "Hello world\nThis is a note", }, { name: "with front matter", input: "---\ntitle: Test\ntags: [a, b]\n---\nHello world\nThis is a note\n", want: "Hello world\nThis is a note\n", }, { name: "only front matter", input: "---\ntitle: Test\n---\n", want: "", }, { name: "unclosed front matter", input: "---\ntitle: Test\nno closing delimiter", want: "---\ntitle: Test\nno closing delimiter", }, { name: "empty string", input: "", want: "", }, { name: "front matter with leading newlines stripped", input: "---\nkey: val\n---\n\n\nBody here\n", want: "Body here\n", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := stripFrontMatter(tt.input) if got != tt.want { t.Errorf("stripFrontMatter() = %q, want %q", got, tt.want) } }) } }