feat: filter and search by tag

This commit is contained in:
2026-02-03 09:53:08 +01:00
parent cb11e34798
commit 229223f77a
9 changed files with 147 additions and 14 deletions

View File

@ -277,3 +277,31 @@ func TestHandlerTags_Remove(t *testing.T) {
t.Fatalf("expected tag to be removed, got %+v", n.Tags)
}
}
func TestHandlerRoot_TagFilter(t *testing.T) {
env := newTestEnv(t)
if err := env.storage.AddTag("a1", "go"); err != nil {
t.Fatalf("seed tag: %v", err)
}
if err := env.storage.AddTag("b2", "rust"); err != nil {
t.Fatalf("seed tag: %v", err)
}
req := httptest.NewRequest(http.MethodGet, "/?tag=go", 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, noteMarker("b2")) {
t.Fatalf("expected non-matching note to be excluded")
}
if !strings.Contains(body, noteMarker("a1")) {
t.Fatalf("expected matching note to be included")
}
}