2019-01-20 20:21:26 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSetGet(t *testing.T) {
|
2024-05-08 17:13:03 +00:00
|
|
|
cfg := ReadConfig(":memory:")
|
2019-01-20 20:21:26 +00:00
|
|
|
expected := "value"
|
|
|
|
cfg.Set("test", expected)
|
2019-01-22 00:16:57 +00:00
|
|
|
actual := cfg.Get("test", "NOPE")
|
2019-01-20 20:21:26 +00:00
|
|
|
assert.Equal(t, expected, actual, "Config did not store values")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSetGetArray(t *testing.T) {
|
2024-05-08 17:13:03 +00:00
|
|
|
cfg := ReadConfig(":memory:")
|
2019-01-20 20:21:26 +00:00
|
|
|
expected := []string{"a", "b", "c"}
|
|
|
|
cfg.SetArray("test", expected)
|
2019-01-22 00:16:57 +00:00
|
|
|
actual := cfg.GetArray("test", []string{"NOPE"})
|
2019-01-20 20:21:26 +00:00
|
|
|
assert.Equal(t, expected, actual, "Config did not store values")
|
|
|
|
}
|