Skip to content

Commit

Permalink
fix: add rdb test
Browse files Browse the repository at this point in the history
  • Loading branch information
guangzhixu committed Nov 8, 2024
1 parent fe58d49 commit ba2b075
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions rdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ type Rdb struct {
path string
}

func NewRdb(path string) (*Rdb, error) {
func NewRdb(path string) *Rdb {
return &Rdb{
path: path,
}, nil
}
}

func (r *Rdb) SaveDB() error {
Expand Down
12 changes: 12 additions & 0 deletions rdb_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestRdb(t *testing.T) {
ast := assert.New(t)
rdb := NewRdb("main.go")
ast.Nil(rdb.LoadDB())
}
5 changes: 1 addition & 4 deletions rotom.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ func InitDB(config *Config) (err error) {
db.dict = New()

if config.Save {
db.rdb, err = NewRdb(config.SaveFileName)
if err != nil {
return
}
db.rdb = NewRdb(config.SaveFileName)
log.Debug().Msg("start loading rdb file...")
if err = db.rdb.LoadDB(); err != nil {
return err
Expand Down

0 comments on commit ba2b075

Please sign in to comment.