mirror of
https://github.com/dnote/dnote
synced 2026-03-14 22:45:50 +01:00
Upgrade dependencies (#450)
* Upgrade dependencies. * Fix test * Improve name * Update doc * Upgrade deps * Fix lint * Fix lint Co-authored-by: Sung Won Cho <sung@monomax.sh>
This commit is contained in:
parent
cabe02aa71
commit
96d3c50780
40 changed files with 4415 additions and 5342 deletions
|
|
@ -117,7 +117,7 @@ func TestNoteInsert(t *testing.T) {
|
|||
func() {
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
n := Note{
|
||||
UUID: tc.uuid,
|
||||
|
|
@ -263,7 +263,7 @@ func TestNoteUpdate(t *testing.T) {
|
|||
func() {
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
n1 := Note{
|
||||
UUID: tc.uuid,
|
||||
|
|
@ -360,7 +360,7 @@ func TestNoteUpdateUUID(t *testing.T) {
|
|||
t.Run(fmt.Sprintf("testCase%d", idx), func(t *testing.T) {
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
n1 := Note{
|
||||
UUID: "n1-uuid",
|
||||
|
|
@ -415,7 +415,7 @@ func TestNoteUpdateUUID(t *testing.T) {
|
|||
func TestNoteExpunge(t *testing.T) {
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
n1 := Note{
|
||||
UUID: "n1-uuid",
|
||||
|
|
@ -541,7 +541,7 @@ func TestBookInsert(t *testing.T) {
|
|||
func() {
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
b := Book{
|
||||
UUID: tc.uuid,
|
||||
|
|
@ -622,7 +622,7 @@ func TestBookUpdate(t *testing.T) {
|
|||
func() {
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
b1 := Book{
|
||||
UUID: "b1-uuid",
|
||||
|
|
@ -701,7 +701,7 @@ func TestBookUpdateUUID(t *testing.T) {
|
|||
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
b1 := Book{
|
||||
UUID: "b1-uuid",
|
||||
|
|
@ -752,7 +752,7 @@ func TestBookUpdateUUID(t *testing.T) {
|
|||
func TestBookExpunge(t *testing.T) {
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
b1 := Book{
|
||||
UUID: "b1-uuid",
|
||||
|
|
@ -807,7 +807,7 @@ func TestBookExpunge(t *testing.T) {
|
|||
func TestNoteFTS(t *testing.T) {
|
||||
// set up
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
// execute - insert
|
||||
n := Note{
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func TestInsertSystem(t *testing.T) {
|
|||
t.Run(fmt.Sprintf("insert %s %s", tc.key, tc.val), func(t *testing.T) {
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
// execute
|
||||
tx, err := db.Begin()
|
||||
|
|
@ -96,7 +96,7 @@ func TestUpsertSystem(t *testing.T) {
|
|||
t.Run(fmt.Sprintf("insert %s %s", tc.key, tc.val), func(t *testing.T) {
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "baz", "quz")
|
||||
|
||||
|
|
@ -135,7 +135,7 @@ func TestGetSystem(t *testing.T) {
|
|||
t.Run(fmt.Sprintf("get string value"), func(t *testing.T) {
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
// execute
|
||||
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "foo", "bar")
|
||||
|
|
@ -158,7 +158,7 @@ func TestGetSystem(t *testing.T) {
|
|||
t.Run(fmt.Sprintf("get int64 value"), func(t *testing.T) {
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
// execute
|
||||
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "foo", 1234)
|
||||
|
|
@ -199,7 +199,7 @@ func TestUpdateSystem(t *testing.T) {
|
|||
t.Run(fmt.Sprintf("update %s %s", tc.key, tc.val), func(t *testing.T) {
|
||||
// Setup
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "foo", "fuz")
|
||||
MustExec(t, "inserting a system configuration", db, "INSERT INTO system (key, value) VALUES (?, ?)", "baz", "quz")
|
||||
|
|
@ -239,7 +239,7 @@ func TestGetActiveNote(t *testing.T) {
|
|||
t.Run("not deleted", func(t *testing.T) {
|
||||
// set up
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
n1UUID := "n1-uuid"
|
||||
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n1UUID, "b1-uuid", "n1 content", 1542058875, 1542058876, 1, true, false, true)
|
||||
|
|
@ -269,7 +269,7 @@ func TestGetActiveNote(t *testing.T) {
|
|||
t.Run("deleted", func(t *testing.T) {
|
||||
// set up
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
n1UUID := "n1-uuid"
|
||||
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", n1UUID, "b1-uuid", "n1 content", 1542058875, 1542058876, 1, true, true, true)
|
||||
|
|
@ -293,7 +293,7 @@ func TestGetActiveNote(t *testing.T) {
|
|||
func TestUpdateNoteContent(t *testing.T) {
|
||||
// set up
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
uuid := "n1-uuid"
|
||||
MustExec(t, "inserting n1", db, "INSERT INTO notes (uuid, book_uuid, body, added_on, edited_on, usn, public, deleted, dirty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", uuid, "b1-uuid", "n1 content", 1542058875, 0, 1, false, false, false)
|
||||
|
|
@ -325,7 +325,7 @@ func TestUpdateNoteContent(t *testing.T) {
|
|||
func TestUpdateNoteBook(t *testing.T) {
|
||||
// set up
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
b1UUID := "b1-uuid"
|
||||
b2UUID := "b2-uuid"
|
||||
|
|
@ -362,7 +362,7 @@ func TestUpdateNoteBook(t *testing.T) {
|
|||
func TestUpdateBookName(t *testing.T) {
|
||||
// set up
|
||||
db := InitTestDB(t, "../tmp/dnote-test.db", nil)
|
||||
defer CloseTestDB(t, db)
|
||||
defer TeardownTestDB(t, db)
|
||||
|
||||
b1UUID := "b1-uuid"
|
||||
MustExec(t, "inserting b1", db, "INSERT INTO books (uuid, label, usn, deleted, dirty) VALUES (?, ?, ?, ?, ?)", b1UUID, "b1-label", 8, false, false)
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ type TestDBOptions struct {
|
|||
SkipMigration bool
|
||||
}
|
||||
|
||||
// InitTestDB opens a test database connection
|
||||
// InitTestDB initializes a test database and opens connection to it
|
||||
func InitTestDB(t *testing.T, dbPath string, options *TestDBOptions) *DB {
|
||||
db, err := Open(dbPath)
|
||||
if err != nil {
|
||||
|
|
@ -137,8 +137,8 @@ func InitTestDB(t *testing.T, dbPath string, options *TestDBOptions) *DB {
|
|||
return db
|
||||
}
|
||||
|
||||
// CloseTestDB closes the test database
|
||||
func CloseTestDB(t *testing.T, db *DB) {
|
||||
// TeardownTestDB closes the test database and removes the its file
|
||||
func TeardownTestDB(t *testing.T, db *DB) {
|
||||
if err := db.Close(); err != nil {
|
||||
t.Fatal(errors.Wrap(err, "closing database"))
|
||||
}
|
||||
|
|
@ -148,7 +148,8 @@ func CloseTestDB(t *testing.T, db *DB) {
|
|||
}
|
||||
}
|
||||
|
||||
// OpenTestDB opens the database connection to the test database
|
||||
// OpenTestDB opens the database connection to a test database
|
||||
// without initializing any schema
|
||||
func OpenTestDB(t *testing.T, dnoteDir string) *DB {
|
||||
dbPath := fmt.Sprintf("%s/%s", dnoteDir, consts.DnoteDBFileName)
|
||||
db, err := Open(dbPath)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue