fix: changed detected by scanner but no updated by render layer
This commit is contained in:
@ -113,6 +113,13 @@ func (s *SQLiteStorage) Create(n *note.Note) error {
|
||||
_, err := s.db.Exec(`
|
||||
INSERT INTO notes (id, path, title, content, updated_at, size, published)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(id) DO UPDATE SET
|
||||
path = excluded.path,
|
||||
title = excluded.title,
|
||||
content = excluded.content,
|
||||
updated_at = excluded.updated_at,
|
||||
size = excluded.size,
|
||||
published = excluded.published
|
||||
`,
|
||||
n.ID,
|
||||
n.Path,
|
||||
|
||||
@ -211,3 +211,28 @@ func TestSQLiteStorage_SearchByTag(t *testing.T) {
|
||||
t.Fatalf("expected tag match to be n2")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSQLiteStorage_Create_Upsert(t *testing.T) {
|
||||
st := newSQLiteStorage(t)
|
||||
|
||||
ts := time.Date(2026, 2, 3, 12, 0, 0, 0, time.UTC)
|
||||
n := sampleNote("n1", "notes/alpha.md", "Alpha", "one", ts)
|
||||
if err := st.Create(n); err != nil {
|
||||
t.Fatalf("create note: %v", err)
|
||||
}
|
||||
|
||||
n.Content = "updated"
|
||||
n.Title = "Alpha Updated"
|
||||
n.UpdatedAt = ts.Add(2 * time.Hour)
|
||||
if err := st.Create(n); err != nil {
|
||||
t.Fatalf("upsert note: %v", err)
|
||||
}
|
||||
|
||||
got, err := st.Get("n1")
|
||||
if err != nil {
|
||||
t.Fatalf("get note: %v", err)
|
||||
}
|
||||
if got.Title != "Alpha Updated" || got.Content != "updated" {
|
||||
t.Fatalf("expected note to be updated, got %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user