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

@ -187,3 +187,27 @@ func TestSQLiteStorage_Tags(t *testing.T) {
t.Fatalf("expected remaining tag rust, got %+v", tags)
}
}
func TestSQLiteStorage_SearchByTag(t *testing.T) {
st := newSQLiteStorage(t)
ts := time.Date(2026, 2, 3, 12, 0, 0, 0, time.UTC)
if err := st.Create(sampleNote("n1", "notes/alpha.md", "Alpha", "no match", ts)); err != nil {
t.Fatalf("create note: %v", err)
}
if err := st.Create(sampleNote("n2", "notes/beta.md", "Beta", "content", ts)); err != nil {
t.Fatalf("create note: %v", err)
}
if err := st.AddTag("n2", "Go"); err != nil {
t.Fatalf("add tag: %v", err)
}
results := st.Search("go")
if len(results) != 1 {
t.Fatalf("expected 1 result, got %d", len(results))
}
if results[0].ID != "n2" {
t.Fatalf("expected tag match to be n2")
}
}