|
|
|
@ -8,7 +8,6 @@ import (
|
|
|
|
|
"github.com/mickael-menu/zk/core/note"
|
|
|
|
|
"github.com/mickael-menu/zk/util"
|
|
|
|
|
"github.com/mickael-menu/zk/util/paths"
|
|
|
|
|
"github.com/mickael-menu/zk/util/test"
|
|
|
|
|
"github.com/mickael-menu/zk/util/test/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -17,31 +16,31 @@ func TestNoteDAOIndexed(t *testing.T) {
|
|
|
|
|
expected := []paths.Metadata{
|
|
|
|
|
{
|
|
|
|
|
Path: "f39c8.md",
|
|
|
|
|
Modified: time.Date(2020, 1, 20, 8, 52, 42, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 1, 20, 8, 52, 42, 0, time.UTC),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: "index.md",
|
|
|
|
|
Modified: time.Date(2019, 12, 4, 12, 17, 21, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2019, 12, 4, 12, 17, 21, 0, time.UTC),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: "log/2021-01-03.md",
|
|
|
|
|
Modified: time.Date(2020, 11, 22, 16, 27, 45, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 11, 22, 16, 27, 45, 0, time.UTC),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: "log/2021-01-04.md",
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.UTC),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: "log/2021-02-04.md",
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.UTC),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: "ref/test/a.md",
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.UTC),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Path: "ref/test/b.md",
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.UTC),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -63,8 +62,8 @@ func TestNoteDAOAdd(t *testing.T) {
|
|
|
|
|
Title: "Added note",
|
|
|
|
|
Body: "Note body",
|
|
|
|
|
WordCount: 2,
|
|
|
|
|
Created: test.Date("2019-11-19T15:33:31+01:00"),
|
|
|
|
|
Modified: test.Date("2020-01-16T16:04:59+01:00"),
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 11, 22, 16, 49, 47, 0, time.UTC),
|
|
|
|
|
Checksum: "check",
|
|
|
|
|
})
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
@ -77,8 +76,8 @@ func TestNoteDAOAdd(t *testing.T) {
|
|
|
|
|
Body: "Note body",
|
|
|
|
|
WordCount: 2,
|
|
|
|
|
Checksum: "check",
|
|
|
|
|
Created: test.Date("2019-11-19T15:33:31+01:00"),
|
|
|
|
|
Modified: test.Date("2020-01-16T16:04:59+01:00"),
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 11, 22, 16, 49, 47, 0, time.UTC),
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -97,10 +96,10 @@ func TestNoteDAOUpdate(t *testing.T) {
|
|
|
|
|
Path: "ref/test/a.md",
|
|
|
|
|
Title: "Updated note",
|
|
|
|
|
Body: "Updated body",
|
|
|
|
|
WordCount: 42,
|
|
|
|
|
Created: test.Date("2020-11-22T16:49:47+01:00"),
|
|
|
|
|
Modified: test.Date("2020-11-22T16:49:47+01:00"),
|
|
|
|
|
Checksum: "updated checksum",
|
|
|
|
|
WordCount: 42,
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 11, 22, 16, 49, 47, 0, time.UTC),
|
|
|
|
|
})
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
|
|
|
|
@ -110,10 +109,10 @@ func TestNoteDAOUpdate(t *testing.T) {
|
|
|
|
|
Path: "ref/test/a.md",
|
|
|
|
|
Title: "Updated note",
|
|
|
|
|
Body: "Updated body",
|
|
|
|
|
WordCount: 42,
|
|
|
|
|
Checksum: "updated checksum",
|
|
|
|
|
Created: test.Date("2019-11-20T20:32:56+01:00"),
|
|
|
|
|
Modified: test.Date("2020-11-22T16:49:47+01:00"),
|
|
|
|
|
WordCount: 42,
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 11, 22, 16, 49, 47, 0, time.UTC),
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -150,8 +149,8 @@ func TestNoteDAOFindAll(t *testing.T) {
|
|
|
|
|
Title: "A nested note",
|
|
|
|
|
Body: "This one is in a sub sub directory",
|
|
|
|
|
WordCount: 8,
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.Local),
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.UTC),
|
|
|
|
|
Checksum: "yvwbae",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -162,8 +161,8 @@ func TestNoteDAOFindAll(t *testing.T) {
|
|
|
|
|
Title: "An interesting note",
|
|
|
|
|
Body: "Its content will surprise you",
|
|
|
|
|
WordCount: 5,
|
|
|
|
|
Created: time.Date(2020, 1, 19, 10, 58, 41, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 1, 20, 8, 52, 42, 0, time.Local),
|
|
|
|
|
Created: time.Date(2020, 1, 19, 10, 58, 41, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 1, 20, 8, 52, 42, 0, time.UTC),
|
|
|
|
|
Checksum: "irkwyc",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -174,8 +173,8 @@ func TestNoteDAOFindAll(t *testing.T) {
|
|
|
|
|
Title: "Another nested note",
|
|
|
|
|
Body: "It shall appear before b.md",
|
|
|
|
|
WordCount: 5,
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.Local),
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.UTC),
|
|
|
|
|
Checksum: "iecywst",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -186,8 +185,8 @@ func TestNoteDAOFindAll(t *testing.T) {
|
|
|
|
|
Title: "February 4, 2021",
|
|
|
|
|
Body: "A third daily note",
|
|
|
|
|
WordCount: 4,
|
|
|
|
|
Created: time.Date(2020, 11, 29, 8, 20, 18, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.Local),
|
|
|
|
|
Created: time.Date(2020, 11, 29, 8, 20, 18, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.UTC),
|
|
|
|
|
Checksum: "earkte",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -198,8 +197,8 @@ func TestNoteDAOFindAll(t *testing.T) {
|
|
|
|
|
Title: "Index",
|
|
|
|
|
Body: "Index of the Zettelkasten",
|
|
|
|
|
WordCount: 4,
|
|
|
|
|
Created: time.Date(2019, 12, 4, 11, 59, 11, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2019, 12, 4, 12, 17, 21, 0, time.Local),
|
|
|
|
|
Created: time.Date(2019, 12, 4, 11, 59, 11, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2019, 12, 4, 12, 17, 21, 0, time.UTC),
|
|
|
|
|
Checksum: "iaefhv",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -210,8 +209,8 @@ func TestNoteDAOFindAll(t *testing.T) {
|
|
|
|
|
Title: "January 3, 2021",
|
|
|
|
|
Body: "A daily note",
|
|
|
|
|
WordCount: 3,
|
|
|
|
|
Created: time.Date(2020, 11, 22, 16, 27, 45, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 11, 22, 16, 27, 45, 0, time.Local),
|
|
|
|
|
Created: time.Date(2020, 11, 22, 16, 27, 45, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 11, 22, 16, 27, 45, 0, time.UTC),
|
|
|
|
|
Checksum: "qwfpgj",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -222,8 +221,8 @@ func TestNoteDAOFindAll(t *testing.T) {
|
|
|
|
|
Title: "January 4, 2021",
|
|
|
|
|
Body: "A second daily note",
|
|
|
|
|
WordCount: 4,
|
|
|
|
|
Created: time.Date(2020, 11, 29, 8, 20, 18, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.Local),
|
|
|
|
|
Created: time.Date(2020, 11, 29, 8, 20, 18, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.UTC),
|
|
|
|
|
Checksum: "arstde",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -239,8 +238,8 @@ func TestNoteDAOFindLimit(t *testing.T) {
|
|
|
|
|
Title: "A nested note",
|
|
|
|
|
Body: "This one is in a sub sub directory",
|
|
|
|
|
WordCount: 8,
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.Local),
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.UTC),
|
|
|
|
|
Checksum: "yvwbae",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -251,8 +250,8 @@ func TestNoteDAOFindLimit(t *testing.T) {
|
|
|
|
|
Title: "An interesting note",
|
|
|
|
|
Body: "Its content will surprise you",
|
|
|
|
|
WordCount: 5,
|
|
|
|
|
Created: time.Date(2020, 1, 19, 10, 58, 41, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 1, 20, 8, 52, 42, 0, time.Local),
|
|
|
|
|
Created: time.Date(2020, 1, 19, 10, 58, 41, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 1, 20, 8, 52, 42, 0, time.UTC),
|
|
|
|
|
Checksum: "irkwyc",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -272,8 +271,8 @@ func TestNoteDAOFindMatch(t *testing.T) {
|
|
|
|
|
Title: "Index",
|
|
|
|
|
Body: "Index of the Zettelkasten",
|
|
|
|
|
WordCount: 4,
|
|
|
|
|
Created: time.Date(2019, 12, 4, 11, 59, 11, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2019, 12, 4, 12, 17, 21, 0, time.Local),
|
|
|
|
|
Created: time.Date(2019, 12, 4, 11, 59, 11, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2019, 12, 4, 12, 17, 21, 0, time.UTC),
|
|
|
|
|
Checksum: "iaefhv",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -284,8 +283,8 @@ func TestNoteDAOFindMatch(t *testing.T) {
|
|
|
|
|
Title: "January 3, 2021",
|
|
|
|
|
Body: "A daily note",
|
|
|
|
|
WordCount: 3,
|
|
|
|
|
Created: time.Date(2020, 11, 22, 16, 27, 45, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 11, 22, 16, 27, 45, 0, time.Local),
|
|
|
|
|
Created: time.Date(2020, 11, 22, 16, 27, 45, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 11, 22, 16, 27, 45, 0, time.UTC),
|
|
|
|
|
Checksum: "qwfpgj",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -296,8 +295,8 @@ func TestNoteDAOFindMatch(t *testing.T) {
|
|
|
|
|
Title: "January 4, 2021",
|
|
|
|
|
Body: "A second daily note",
|
|
|
|
|
WordCount: 4,
|
|
|
|
|
Created: time.Date(2020, 11, 29, 8, 20, 18, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.Local),
|
|
|
|
|
Created: time.Date(2020, 11, 29, 8, 20, 18, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.UTC),
|
|
|
|
|
Checksum: "arstde",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -308,8 +307,8 @@ func TestNoteDAOFindMatch(t *testing.T) {
|
|
|
|
|
Title: "February 4, 2021",
|
|
|
|
|
Body: "A third daily note",
|
|
|
|
|
WordCount: 4,
|
|
|
|
|
Created: time.Date(2020, 11, 29, 8, 20, 18, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.Local),
|
|
|
|
|
Created: time.Date(2020, 11, 29, 8, 20, 18, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.UTC),
|
|
|
|
|
Checksum: "earkte",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -330,8 +329,8 @@ func TestNoteDAOFindInPath(t *testing.T) {
|
|
|
|
|
Title: "January 3, 2021",
|
|
|
|
|
Body: "A daily note",
|
|
|
|
|
WordCount: 3,
|
|
|
|
|
Created: time.Date(2020, 11, 22, 16, 27, 45, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 11, 22, 16, 27, 45, 0, time.Local),
|
|
|
|
|
Created: time.Date(2020, 11, 22, 16, 27, 45, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 11, 22, 16, 27, 45, 0, time.UTC),
|
|
|
|
|
Checksum: "qwfpgj",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -342,8 +341,8 @@ func TestNoteDAOFindInPath(t *testing.T) {
|
|
|
|
|
Title: "January 4, 2021",
|
|
|
|
|
Body: "A second daily note",
|
|
|
|
|
WordCount: 4,
|
|
|
|
|
Created: time.Date(2020, 11, 29, 8, 20, 18, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.Local),
|
|
|
|
|
Created: time.Date(2020, 11, 29, 8, 20, 18, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2020, 11, 29, 8, 20, 18, 0, time.UTC),
|
|
|
|
|
Checksum: "arstde",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -364,8 +363,8 @@ func TestNoteDAOFindInMultiplePath(t *testing.T) {
|
|
|
|
|
Title: "A nested note",
|
|
|
|
|
Body: "This one is in a sub sub directory",
|
|
|
|
|
WordCount: 8,
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.Local),
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.UTC),
|
|
|
|
|
Checksum: "yvwbae",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -376,8 +375,8 @@ func TestNoteDAOFindInMultiplePath(t *testing.T) {
|
|
|
|
|
Title: "Another nested note",
|
|
|
|
|
Body: "It shall appear before b.md",
|
|
|
|
|
WordCount: 5,
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.Local),
|
|
|
|
|
Created: time.Date(2019, 11, 20, 20, 32, 56, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2019, 11, 20, 20, 34, 6, 0, time.UTC),
|
|
|
|
|
Checksum: "iecywst",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -388,8 +387,8 @@ func TestNoteDAOFindInMultiplePath(t *testing.T) {
|
|
|
|
|
Title: "Index",
|
|
|
|
|
Body: "Index of the Zettelkasten",
|
|
|
|
|
WordCount: 4,
|
|
|
|
|
Created: time.Date(2019, 12, 4, 11, 59, 11, 0, time.Local),
|
|
|
|
|
Modified: time.Date(2019, 12, 4, 12, 17, 21, 0, time.Local),
|
|
|
|
|
Created: time.Date(2019, 12, 4, 11, 59, 11, 0, time.UTC),
|
|
|
|
|
Modified: time.Date(2019, 12, 4, 12, 17, 21, 0, time.UTC),
|
|
|
|
|
Checksum: "iaefhv",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|