(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func 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 | |
| 49 | func TestViewNoteContentOnly(t *testing.T) { |
| 50 | db := database.InitTestMemoryDB(t) |
nothing calls this directly
no test coverage detected