(t *testing.T)
| 280 | } |
| 281 | |
| 282 | func 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 | |
| 313 | func TestUpdateNoteBook(t *testing.T) { |
| 314 | // set up |
nothing calls this directly
no test coverage detected