MCPcopy Index your code
hub / github.com/dnote/dnote / TestUpdateNoteContent

Function TestUpdateNoteContent

pkg/cli/database/queries_test.go:282–311  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

280}
281
282func TestUpdateNoteContent(t *testing.T) {
283 // set up
284 db := InitTestMemoryDB(t)
285
286 uuid := "n1-uuid"
287 MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", uuid, "b1-uuid", "n1 content", 1542058875, 0, 1, false, false)
288
289 var rowid int
290 MustScan(t, "getting rowid", db.QueryRow("SELECT rowid FROM notes WHERE uuid = ?", uuid), &rowid)
291
292 // execute
293 c := clock.NewMock()
294 now := time.Date(2017, time.March, 14, 21, 15, 0, 0, time.UTC)
295 c.SetNow(now)
296
297 err := UpdateNoteContent(db, c, rowid, "n1 content updated")
298 if err != nil {
299 t.Fatal(errors.Wrap(err, "executing"))
300 }
301
302 var content string
303 var editedOn int
304 var dirty bool
305
306 MustScan(t, "getting the note record", db.QueryRow("SELECT body, edited_on, dirty FROM notes WHERE rowid = ?", rowid), &content, &editedOn, &dirty)
307
308 assert.Equal(t, content, "n1 content updated", "content mismatch")
309 assert.Equal(t, int64(editedOn), now.UnixNano(), "editedOn mismatch")
310 assert.Equal(t, dirty, true, "dirty mismatch")
311}
312
313func TestUpdateNoteBook(t *testing.T) {
314 // set up

Callers

nothing calls this directly

Calls 8

SetNowMethod · 0.95
NewMockFunction · 0.92
EqualFunction · 0.92
InitTestMemoryDBFunction · 0.85
MustScanFunction · 0.85
UpdateNoteContentFunction · 0.85
MustExecFunction · 0.70
QueryRowMethod · 0.65

Tested by

no test coverage detected