mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
config: replace defaultConfig with a thread-safe in-memory implementation
This commit is contained in:
committed by
Nick Craig-Wood
parent
6ef7178ee4
commit
732bc08ced
42
fs/config/default_storage_test.go
Normal file
42
fs/config/default_storage_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDefaultStorage(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
|
||||
ds := newDefaultStorage()
|
||||
|
||||
section := "test"
|
||||
key := "key"
|
||||
val := "something"
|
||||
ds.SetValue(section, key, val)
|
||||
ds.SetValue("some other section", key, val)
|
||||
|
||||
v, hasVal := ds.GetValue(section, key)
|
||||
a.True(hasVal)
|
||||
a.Equal(val, v)
|
||||
|
||||
a.ElementsMatch([]string{section, "some other section"}, ds.GetSectionList())
|
||||
a.True(ds.HasSection(section))
|
||||
a.False(ds.HasSection("nope"))
|
||||
|
||||
a.Equal([]string{key}, ds.GetKeyList(section))
|
||||
|
||||
_, err := ds.Serialize()
|
||||
a.NoError(err)
|
||||
|
||||
a.True(ds.DeleteKey(section, key))
|
||||
a.False(ds.DeleteKey(section, key))
|
||||
a.False(ds.DeleteKey("not there", key))
|
||||
|
||||
_, hasVal = ds.GetValue(section, key)
|
||||
a.False(hasVal)
|
||||
|
||||
ds.DeleteSection(section)
|
||||
a.False(ds.HasSection(section))
|
||||
}
|
||||
Reference in New Issue
Block a user