diff --git a/config/config_test.go b/config/config_test.go new file mode 100644 index 0000000000..9acdeb1f33 --- /dev/null +++ b/config/config_test.go @@ -0,0 +1,26 @@ +package config + +import ( + "reflect" + "strings" + "testing" +) + +func TestLoad(t *testing.T) { + sampleConfig := "{\"server\": {\"addr\":\"testAddr\",\"tls_cert_file\":\"testCertFile\",\"tls_key_file\":\"testKeyFile\"}}" + sampleConfigStruct := &Configuration{ + Server: ServerConf{ + Addr: "testAddr", + TLSCertFile: "testCertFile", + TLSKeyFile: "testKeyFile", + }, + } + conf, err := Load(strings.NewReader(sampleConfig)) + if err != nil { + t.Fatalf("Error parsing config: %s", err.Error()) + } + + if !reflect.DeepEqual(conf, sampleConfigStruct) { + t.Fatalf("Parsed config did not match expected.") + } +}