feat(release): v0.3.0

commit 533ac4e58256e6520a86af964fcf4c2f9a98d4ba
Author: adminoo <git@kadath.corp>
Date:   Mon Feb 23 18:52:59 2026 +0100

    feat: freebsd release tarball generator

commit 874fb63fd0
Author: adminoo <git@kadath.corp>
Date:   Mon Feb 23 14:05:24 2026 +0100

    feat: bump changelog

commit 46ab7e2911
Author: adminoo <git@kadath.corp>
Date:   Mon Feb 23 13:58:14 2026 +0100

    feat: margin and page breaks

commit 44751a808a
Author: adminoo <git@kadath.corp>
Date:   Mon Feb 23 13:57:56 2026 +0100

    feat: picture are worth thousand words

commit a5683428e0
Author: adminoo <git@kadath.corp>
Date:   Mon Feb 23 13:39:00 2026 +0100

    feat: navigate individual sections

commit 0d9b7c4e7b
Author: adminoo <git@kadath.corp>
Date:   Mon Feb 23 13:38:19 2026 +0100

    feat: make use of vendoring
This commit is contained in:
2026-02-23 19:17:17 +01:00
parent b571588b15
commit 5fdcede6f8
11 changed files with 507 additions and 11 deletions

View File

@ -443,3 +443,139 @@ func TestGroupNotesByFolder(t *testing.T) {
t.Fatalf("unexpected notes group: %+v", groups[1])
}
}
func TestHandlerNotes_SectionLinks(t *testing.T) {
env := newTestEnv(t)
sectionNote := &note.Note{
ID: "s1",
Title: "Sections",
Content: "# Sections\nIntro\n## 2026-01-01 - First\nFirst body\n## Glossary\nTerm A\n## Glossary\nTerm B\n",
Path: "notes/sections.md",
UpdatedAt: time.Date(2026, 1, 4, 10, 0, 0, 0, time.UTC),
}
if err := env.storage.Create(sectionNote); err != nil {
t.Fatalf("create note: %v", err)
}
req := httptest.NewRequest(http.MethodGet, "/notes/s1", nil)
rec := httptest.NewRecorder()
env.handler.ServeHTTP(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("expected status 200, got %d", rec.Code)
}
body := rec.Body.String()
if !strings.Contains(body, `href="/notes/s1/sections/2026-01-01-first"`) {
t.Fatalf("expected link for first section")
}
if !strings.Contains(body, `href="/notes/s1/sections/glossary"`) {
t.Fatalf("expected link for glossary section")
}
if !strings.Contains(body, `href="/notes/s1/sections/glossary-2"`) {
t.Fatalf("expected link for duplicate glossary section")
}
}
func TestHandlerNotes_SectionRoute(t *testing.T) {
env := newTestEnv(t)
sectionNote := &note.Note{
ID: "s1",
Title: "Sections",
Content: "# Sections\nIntro\n## 2026-01-01 - First\nFirst body\n## Glossary\nTerm A\n## Glossary\nTerm B\n",
Path: "notes/sections.md",
UpdatedAt: time.Date(2026, 1, 4, 10, 0, 0, 0, time.UTC),
}
if err := env.storage.Create(sectionNote); err != nil {
t.Fatalf("create note: %v", err)
}
req := httptest.NewRequest(http.MethodGet, "/notes/s1/sections/glossary", nil)
rec := httptest.NewRecorder()
env.handler.ServeHTTP(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("expected status 200, got %d", rec.Code)
}
body := rec.Body.String()
if !strings.Contains(body, "<h2>Glossary</h2>") {
t.Fatalf("expected glossary heading to be rendered")
}
if !strings.Contains(body, "Term A") {
t.Fatalf("expected first glossary content")
}
if strings.Contains(body, "First body") {
t.Fatalf("expected other section content to be excluded")
}
if strings.Contains(body, "Term B") {
t.Fatalf("expected second glossary content to be excluded")
}
}
func TestHandlerNotes_SectionRoute_Duplicate(t *testing.T) {
env := newTestEnv(t)
sectionNote := &note.Note{
ID: "s1",
Title: "Sections",
Content: "# Sections\nIntro\n## Glossary\nTerm A\n## Glossary\nTerm B\n",
Path: "notes/sections.md",
UpdatedAt: time.Date(2026, 1, 4, 10, 0, 0, 0, time.UTC),
}
if err := env.storage.Create(sectionNote); err != nil {
t.Fatalf("create note: %v", err)
}
req := httptest.NewRequest(http.MethodGet, "/notes/s1/sections/glossary-2", nil)
rec := httptest.NewRecorder()
env.handler.ServeHTTP(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("expected status 200, got %d", rec.Code)
}
body := rec.Body.String()
if !strings.Contains(body, "<h2>Glossary</h2>") {
t.Fatalf("expected glossary heading to be rendered")
}
if !strings.Contains(body, "Term B") {
t.Fatalf("expected second glossary content")
}
if strings.Contains(body, "Term A") {
t.Fatalf("expected first glossary content to be excluded")
}
}
func TestHandlerNotes_SectionRoute_NotFound(t *testing.T) {
env := newTestEnv(t)
sectionNote := &note.Note{
ID: "s1",
Title: "Sections",
Content: "# Sections\n## Alpha\nA\n",
Path: "notes/sections.md",
UpdatedAt: time.Date(2026, 1, 4, 10, 0, 0, 0, time.UTC),
}
if err := env.storage.Create(sectionNote); err != nil {
t.Fatalf("create note: %v", err)
}
req := httptest.NewRequest(http.MethodGet, "/notes/s1/sections/missing", nil)
rec := httptest.NewRecorder()
env.handler.ServeHTTP(rec, req)
if rec.Code != http.StatusNotFound {
t.Fatalf("expected status 404, got %d", rec.Code)
}
}