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

Function TestUpdateBookName

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

Source from the content-addressed store, hash-verified

347}
348
349func TestUpdateBookName(t *testing.T) {
350 // set up
351 db := InitTestMemoryDB(t)
352
353 b1UUID := "b1-uuid"
354 MustExec(t, "inserting b1", db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", b1UUID, "b1-label", 8, false, false)
355
356 // execute
357 err := UpdateBookName(db, b1UUID, "b1-label-edited")
358 if err != nil {
359 t.Fatal(errors.Wrap(err, "executing"))
360 }
361
362 // test
363 var b1 Book
364 MustScan(t, "getting the note record", db.QueryRow("SELECT uuid, label, dirty, usn, deleted FROM books WHERE uuid = ?", b1UUID), &b1.UUID, &b1.Label, &b1.Dirty, &b1.USN, &b1.Deleted)
365 assert.Equal(t, b1.UUID, b1UUID, "UUID mismatch")
366 assert.Equal(t, b1.Label, "b1-label-edited", "Label mismatch")
367 assert.Equal(t, b1.Dirty, true, "Dirty mismatch")
368 assert.Equal(t, b1.USN, 8, "USN mismatch")
369 assert.Equal(t, b1.Deleted, false, "Deleted mismatch")
370}

Callers

nothing calls this directly

Calls 6

EqualFunction · 0.92
InitTestMemoryDBFunction · 0.85
UpdateBookNameFunction · 0.85
MustScanFunction · 0.85
MustExecFunction · 0.70
QueryRowMethod · 0.65

Tested by

no test coverage detected