github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/fs/config/default_storage_test.go (about) 1 package config 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestDefaultStorage(t *testing.T) { 10 a := assert.New(t) 11 12 ds := newDefaultStorage() 13 14 section := "test" 15 key := "key" 16 val := "something" 17 ds.SetValue(section, key, val) 18 ds.SetValue("some other section", key, val) 19 20 v, hasVal := ds.GetValue(section, key) 21 a.True(hasVal) 22 a.Equal(val, v) 23 24 a.ElementsMatch([]string{section, "some other section"}, ds.GetSectionList()) 25 a.True(ds.HasSection(section)) 26 a.False(ds.HasSection("nope")) 27 28 a.Equal([]string{key}, ds.GetKeyList(section)) 29 30 _, err := ds.Serialize() 31 a.NoError(err) 32 33 a.True(ds.DeleteKey(section, key)) 34 a.False(ds.DeleteKey(section, key)) 35 a.False(ds.DeleteKey("not there", key)) 36 37 _, hasVal = ds.GetValue(section, key) 38 a.False(hasVal) 39 40 ds.DeleteSection(section) 41 a.False(ds.HasSection(section)) 42 }