From 3f9e66eb8fdf99373323a7bd7a31b51c3598379f Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Mon, 20 Apr 2015 14:36:48 -0700 Subject: [PATCH] adding tests for config --- config/config_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 config/config_test.go 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.") + } +}