feat: tag system

This commit is contained in:
2026-02-03 09:41:03 +01:00
parent 3f5cf0d673
commit cb11e34798
11 changed files with 397 additions and 10 deletions

View File

@ -157,3 +157,33 @@ func TestSQLiteStorage_Count(t *testing.T) {
t.Fatalf("expected count 2")
}
}
func TestSQLiteStorage_Tags(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", "one", ts)); err != nil {
t.Fatalf("create note: %v", err)
}
if err := st.AddTag("n1", "go"); err != nil {
t.Fatalf("add tag: %v", err)
}
if err := st.AddTag("n1", "rust"); err != nil {
t.Fatalf("add tag: %v", err)
}
tags := st.GetTags("n1")
if len(tags) != 2 {
t.Fatalf("expected 2 tags, got %d", len(tags))
}
if err := st.RemoveTag("n1", "go"); err != nil {
t.Fatalf("remove tag: %v", err)
}
tags = st.GetTags("n1")
if len(tags) != 1 || tags[0] != "rust" {
t.Fatalf("expected remaining tag rust, got %+v", tags)
}
}