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

Function TestViewNote

pkg/cli/cmd/view/note_test.go:28–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestViewNote(t *testing.T) {
29 db := database.InitTestMemoryDB(t)
30 defer db.Close()
31
32 bookUUID := "test-book-uuid"
33 database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", bookUUID, "golang")
34 database.MustExec(t, "inserting note", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)",
35 "note-uuid", bookUUID, "test note content", 1515199943000000000)
36
37 ctx := context.DnoteCtx{DB: db}
38 var buf bytes.Buffer
39
40 err := viewNote(ctx, &buf, "1", false)
41 if err != nil {
42 t.Fatal(err)
43 }
44
45 got := buf.String()
46 assert.Equal(t, strings.Contains(got, "test note content"), true, "should contain note content")
47}
48
49func TestViewNoteContentOnly(t *testing.T) {
50 db := database.InitTestMemoryDB(t)

Callers

nothing calls this directly

Calls 5

InitTestMemoryDBFunction · 0.92
MustExecFunction · 0.92
EqualFunction · 0.92
viewNoteFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected