41 lines
888 B
Go
41 lines
888 B
Go
package gosimpleconf
|
|
|
|
import "testing"
|
|
|
|
func TestConfigureWithDefaults(t *testing.T) {
|
|
defaultMap := ConfigMap{
|
|
"some": "thing",
|
|
"cool": "1337",
|
|
}
|
|
|
|
filename := "idontexist_123456789"
|
|
|
|
conf, err := ConfigureWithDefaults(filename, defaultMap)
|
|
if err != nil {
|
|
t.Errorf("unexpected error: %v", err)
|
|
}
|
|
|
|
validateMap(t, conf, defaultMap)
|
|
}
|
|
|
|
func TestConfigure(t *testing.T) {
|
|
filename := "test.conf"
|
|
expectedMap := ConfigMap{
|
|
"url": "www.wisellama.rocks",
|
|
"number_of_widgets": "1337",
|
|
"pi": "3.141592653589793238462643383",
|
|
"environment": "production",
|
|
"name": "Dude guy",
|
|
"description": "Just some dude it was",
|
|
"base64_tacos": "dGFjb3M=",
|
|
"a": "b=c",
|
|
}
|
|
|
|
conf, err := Configure(filename)
|
|
if err != nil {
|
|
t.Errorf("unexpected error: %v", err)
|
|
}
|
|
|
|
validateMap(t, conf, expectedMap)
|
|
}
|