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

Function TestGetNote_nonexistent

pkg/server/operations/notes_test.go:95–124  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func TestGetNote_nonexistent(t *testing.T) {
96 db := testutils.InitMemoryDB(t)
97
98 user := testutils.SetupUserData(db, "user@test.com", "password123")
99
100 b1 := database.Book{
101 UUID: testutils.MustUUID(t),
102 UserID: user.ID,
103 Label: "js",
104 }
105 testutils.MustExec(t, db.Save(&b1), "preparing b1")
106
107 n1 := database.Note{
108 UUID: "4fd19336-671e-4ff3-8f22-662b80e22edc",
109 UserID: user.ID,
110 BookUUID: b1.UUID,
111 Body: "n1 content",
112 Deleted: false,
113 }
114 testutils.MustExec(t, db.Save(&n1), "preparing n1")
115
116 nonexistentUUID := "4fd19336-671e-4ff3-8f22-662b80e22edd"
117 note, ok, err := GetNote(db, nonexistentUUID, &user)
118 if err != nil {
119 t.Fatal(errors.Wrap(err, "executing"))
120 }
121
122 assert.Equal(t, ok, false, "ok mismatch")
123 assert.DeepEqual(t, note, database.Note{}, "note mismatch")
124}

Callers

nothing calls this directly

Calls 7

InitMemoryDBFunction · 0.92
SetupUserDataFunction · 0.92
MustUUIDFunction · 0.92
MustExecFunction · 0.92
EqualFunction · 0.92
DeepEqualFunction · 0.92
GetNoteFunction · 0.85

Tested by

no test coverage detected