mirror of
https://github.com/mickael-menu/zk
synced 2024-11-15 12:12:56 +00:00
f5b3102deb
* YAML frontmatter as a JSON object in `notes.metadata` * Print metadata from the YAML frontmatter in `list` output using `{{metadata.<key>}}`, e.g. `{{metadata.description}}`. Keys are normalized to lower case. * Start and end offsets for link snippets. * This could be useful to expand backlinks contexts.
48 lines
1008 B
Go
48 lines
1008 B
Go
package sqlite
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mickael-menu/zk/util/fixtures"
|
|
"github.com/mickael-menu/zk/util/test/assert"
|
|
)
|
|
|
|
func TestOpen(t *testing.T) {
|
|
_, err := Open(fixtures.Path("sample.db"))
|
|
assert.Nil(t, err)
|
|
}
|
|
|
|
func TestClose(t *testing.T) {
|
|
db, err := Open(fixtures.Path("sample.db"))
|
|
assert.Nil(t, err)
|
|
err = db.Close()
|
|
assert.Nil(t, err)
|
|
}
|
|
|
|
func TestMigrateFrom0(t *testing.T) {
|
|
db, err := OpenInMemory()
|
|
assert.Nil(t, err)
|
|
|
|
_, err = db.Migrate()
|
|
assert.Nil(t, err)
|
|
// Should be able to migrate twice in a row
|
|
_, err = db.Migrate()
|
|
assert.Nil(t, err)
|
|
|
|
err = db.WithTransaction(func(tx Transaction) error {
|
|
var version int
|
|
err := tx.QueryRow("PRAGMA user_version").Scan(&version)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, version, 3)
|
|
|
|
_, err = tx.Exec(`
|
|
INSERT INTO notes (path, sortable_path, title, body, word_count, checksum)
|
|
VALUES ("ref/tx1.md", "reftx1.md", "A reference", "Content", 1, "qwfpg")
|
|
`)
|
|
assert.Nil(t, err)
|
|
|
|
return nil
|
|
})
|
|
assert.Nil(t, err)
|
|
}
|