package config import ( "io/ioutil" "os" "testing" "github.com/stretchr/testify/assert" ) func TestSetGet(t *testing.T) { storeFile, err := ioutil.TempFile(os.TempDir(), "prefix-") if err != nil { panic(err) } defer os.Remove(storeFile.Name()) cfg := ReadConfig(":memory:", storeFile.Name()) expected := "value" cfg.Set("test", expected) actual := cfg.Get("test", "NOPE") assert.Equal(t, expected, actual, "Config did not store values") } func TestSetGetArray(t *testing.T) { storeFile, err := ioutil.TempFile(os.TempDir(), "prefix-") if err != nil { panic(err) } defer os.Remove(storeFile.Name()) cfg := ReadConfig(":memory:", storeFile.Name()) expected := []string{"a", "b", "c"} cfg.SetArray("test", expected) actual := cfg.GetArray("test", []string{"NOPE"}) assert.Equal(t, expected, actual, "Config did not store values") }