MCPcopy
hub / github.com/dnote/dnote / TestView

Function TestView

pkg/cli/main_test.go:573–633  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

571}
572
573func TestView(t *testing.T) {
574 t.Run("view note by rowid", func(t *testing.T) {
575 _, opts := setupTestEnv(t)
576
577 db, dbPath := database.InitTestFileDB(t)
578 testutils.Setup4(t, db)
579
580 output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view", "1")
581
582 assert.Equal(t, strings.Contains(output, "Booleans have toString()"), true, "should contain note content")
583 assert.Equal(t, strings.Contains(output, "book name"), true, "should show metadata")
584 })
585
586 t.Run("view note content only", func(t *testing.T) {
587 _, opts := setupTestEnv(t)
588
589 db, dbPath := database.InitTestFileDB(t)
590 testutils.Setup4(t, db)
591
592 output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view", "1", "--content-only")
593
594 assert.Equal(t, strings.Contains(output, "Booleans have toString()"), true, "should contain note content")
595 assert.Equal(t, strings.Contains(output, "book name"), false, "should not show metadata")
596 })
597
598 t.Run("list books", func(t *testing.T) {
599 _, opts := setupTestEnv(t)
600
601 db, dbPath := database.InitTestFileDB(t)
602 testutils.Setup1(t, db)
603
604 output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view")
605
606 assert.Equal(t, strings.Contains(output, "js"), true, "should list js book")
607 assert.Equal(t, strings.Contains(output, "linux"), true, "should list linux book")
608 })
609
610 t.Run("list notes in book", func(t *testing.T) {
611 _, opts := setupTestEnv(t)
612
613 db, dbPath := database.InitTestFileDB(t)
614 testutils.Setup2(t, db)
615
616 output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view", "js")
617
618 assert.Equal(t, strings.Contains(output, "n1 body"), true, "should list note 1")
619 assert.Equal(t, strings.Contains(output, "n2 body"), true, "should list note 2")
620 })
621
622 t.Run("view note by book name and rowid", func(t *testing.T) {
623 _, opts := setupTestEnv(t)
624
625 db, dbPath := database.InitTestFileDB(t)
626 testutils.Setup4(t, db)
627
628 output := testutils.RunDnoteCmd(t, opts, binaryName, "--dbPath", dbPath, "view", "js", "2")
629
630 assert.Equal(t, strings.Contains(output, "Date object implements mathematical comparisons"), true, "should contain note content")

Callers

nothing calls this directly

Calls 7

InitTestFileDBFunction · 0.92
Setup4Function · 0.92
RunDnoteCmdFunction · 0.92
EqualFunction · 0.92
Setup1Function · 0.92
Setup2Function · 0.92
setupTestEnvFunction · 0.70

Tested by

no test coverage detected