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

Function TestBookUpdate

pkg/cli/database/models_test.go:550–649  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

548}
549
550func TestBookUpdate(t *testing.T) {
551 testCases := []struct {
552 uuid string
553 label string
554 usn int
555 deleted bool
556 dirty bool
557 newLabel string
558 newUSN int
559 newDeleted bool
560 newDirty bool
561 }{
562 {
563 uuid: "b1-uuid",
564 label: "b1-label",
565 usn: 0,
566 deleted: false,
567 dirty: false,
568 newLabel: "b1-label-edited",
569 newUSN: 0,
570 newDeleted: false,
571 newDirty: true,
572 },
573 {
574 uuid: "b1-uuid",
575 label: "b1-label",
576 usn: 0,
577 deleted: false,
578 dirty: false,
579 newLabel: "",
580 newUSN: 10,
581 newDeleted: true,
582 newDirty: false,
583 },
584 }
585
586 for idx, tc := range testCases {
587 func() {
588 // Setup
589 db := InitTestMemoryDB(t)
590
591 b1 := Book{
592 UUID: "b1-uuid",
593 Label: "b1-label",
594 USN: 1,
595 Deleted: true,
596 Dirty: false,
597 }
598 b2 := Book{
599 UUID: "b2-uuid",
600 Label: "b2-label",
601 USN: 1,
602 Deleted: true,
603 Dirty: false,
604 }
605
606 MustExec(t, fmt.Sprintf("inserting b1 for test case %d", idx), db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", b1.UUID, b1.Label, b1.USN, b1.Deleted, b1.Dirty)
607 MustExec(t, fmt.Sprintf("inserting b2 for test case %d", idx), db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", b2.UUID, b2.Label, b2.USN, b2.Deleted, b2.Dirty)

Callers

nothing calls this directly

Calls 10

UpdateMethod · 0.95
EqualFunction · 0.92
InitTestMemoryDBFunction · 0.85
MustScanFunction · 0.85
MustExecFunction · 0.70
BeginMethod · 0.65
RollbackMethod · 0.65
CommitMethod · 0.65
QueryRowMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected