Skip to content

Commit

Permalink
rename GetConfigOption / SetConfigOption
Browse files Browse the repository at this point in the history
  • Loading branch information
brunnre8 committed Jul 27, 2019
1 parent f9e9fcb commit 36ad5aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ func (db *DB) GetConfigList(prefix string) (*ConfigList, error) {
return cl, nil
}

// GetConfigOption gets config value of key
func (db *DB) GetConfigOption(key string) (string, error) {
// GetConfig gets config value of key
func (db *DB) GetConfig(key string) (string, error) {
ckey := C.CString(key)
defer C.free(unsafe.Pointer(ckey))
var cval *C.char
Expand All @@ -255,8 +255,8 @@ func (db *DB) GetConfigOption(key string) (string, error) {
return C.GoString(cval), nil
}

// SetConfigOption sets config key to value.
func (db *DB) SetConfigOption(key, value string) error {
// SetConfig sets config key to value.
func (db *DB) SetConfig(key, value string) error {
ckey := C.CString(key)
defer C.free(unsafe.Pointer(ckey))
cval := C.CString(value)
Expand Down
24 changes: 12 additions & 12 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,19 @@ func TestSetConfig(t *testing.T) {
defer db.Close()
cfgKey := "search.exclude_tags"
cfgVal := "spam"
if err := db.SetConfigOption(cfgKey, cfgVal); err != nil {
t.Errorf("db.SetConfigOption(%q, %q): unexpected error %s", cfgKey, cfgVal, err)
if err := db.SetConfig(cfgKey, cfgVal); err != nil {
t.Errorf("db.SetConfig(%q, %q): unexpected error %s", cfgKey, cfgVal, err)
}
}

func TestGetConfigOption(t *testing.T) {
func TestGetConfig(t *testing.T) {
db, err := Open(dbPath, DBReadWrite)
if err != nil {
t.Fatalf("Open(%q): unexpected error: %s", dbPath, err)
}
defer db.Close()
if _, err := db.GetConfigOption("blah"); err != nil {
t.Errorf("db.GetConfigOption(\"blah\"): unexpected error %s", err)
if _, err := db.GetConfig("blah"); err != nil {
t.Errorf("db.GetConfig(\"blah\"): unexpected error %s", err)
}
}

Expand All @@ -266,15 +266,15 @@ func TestConfigRoundtrip(t *testing.T) {
defer db.Close()
cfgKey := "search.exclude_tags"
cfgVal := "spam"
if err := db.SetConfigOption(cfgKey, cfgVal); err != nil {
t.Errorf("db.SetConfigOption(%q, %q): unexpected error %s", cfgKey, cfgVal, err)
if err := db.SetConfig(cfgKey, cfgVal); err != nil {
t.Errorf("db.SetConfig(%q, %q): unexpected error %s", cfgKey, cfgVal, err)
}
value, err := db.GetConfigOption(cfgKey)
value, err := db.GetConfig(cfgKey)
if err != nil {
t.Errorf("db.GetConfigOption(%q): unexpected error %s", cfgKey, err)
t.Errorf("db.GetConfig(%q): unexpected error %s", cfgKey, err)
}
if value != cfgVal {
t.Errorf("db.GetConfigOption(%q): want: %q, got %q", cfgKey, cfgVal, value)
t.Errorf("db.GetConfig(%q): want: %q, got %q", cfgKey, cfgVal, value)
}
}

Expand All @@ -286,8 +286,8 @@ func TestConfigListNext(t *testing.T) {
defer db.Close()
cfgKey := "search.exclude_tags"
cfgVal := "spam"
if err := db.SetConfigOption(cfgKey, cfgVal); err != nil {
t.Errorf("db.SetConfigOption(%q, %q): unexpected error %s", cfgKey, cfgVal, err)
if err := db.SetConfig(cfgKey, cfgVal); err != nil {
t.Errorf("db.SetConfig(%q, %q): unexpected error %s", cfgKey, cfgVal, err)
}
cfgList, err := db.GetConfigList("")
if err != nil {
Expand Down

0 comments on commit 36ad5aa

Please sign in to comment.