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

Function TestViewNoteContentOnly

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

Source from the content-addressed store, hash-verified

47}
48
49func TestViewNoteContentOnly(t *testing.T) {
50 db := database.InitTestMemoryDB(t)
51 defer db.Close()
52
53 bookUUID := "test-book-uuid"
54 database.MustExec(t, "inserting book", db, "INSERT INTO books (uuid, label) VALUES (?, ?)", bookUUID, "golang")
55 database.MustExec(t, "inserting note", db, "INSERT INTO notes (uuid, book_uuid, body, added_on) VALUES (?, ?, ?, ?)",
56 "note-uuid", bookUUID, "test note content", 1515199943000000000)
57
58 ctx := context.DnoteCtx{DB: db}
59 var buf bytes.Buffer
60
61 err := viewNote(ctx, &buf, "1", true)
62 if err != nil {
63 t.Fatal(err)
64 }
65
66 got := buf.String()
67 assert.Equal(t, got, "test note content", "should contain only note content")
68}
69
70func TestViewNoteInvalidRowID(t *testing.T) {
71 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