summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/headers/config_test.go27
-rw-r--r--service/http/config_test.go2
2 files changed, 28 insertions, 1 deletions
diff --git a/service/headers/config_test.go b/service/headers/config_test.go
new file mode 100644
index 00000000..e6b9b8ff
--- /dev/null
+++ b/service/headers/config_test.go
@@ -0,0 +1,27 @@
+package headers
+
+import (
+ "encoding/json"
+ "github.com/spiral/roadrunner/service"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+type mockCfg struct{ cfg string }
+
+func (cfg *mockCfg) Get(name string) service.Config { return nil }
+func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) }
+
+func Test_Config_Hydrate_Error1(t *testing.T) {
+ cfg := &mockCfg{`{"request": {"From": "Something"}}`}
+ c := &Config{}
+
+ assert.NoError(t, c.Hydrate(cfg))
+}
+
+func Test_Config_Hydrate_Error2(t *testing.T) {
+ cfg := &mockCfg{`{"dir": "/dir/"`}
+ c := &Config{}
+
+ assert.Error(t, c.Hydrate(cfg))
+}
diff --git a/service/http/config_test.go b/service/http/config_test.go
index 6bb314d8..d8b92247 100644
--- a/service/http/config_test.go
+++ b/service/http/config_test.go
@@ -16,7 +16,7 @@ func (cfg *mockCfg) Get(name string) service.Config { return nil }
func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) }
func Test_Config_Hydrate_Error1(t *testing.T) {
- cfg := &mockCfg{`{"enable": true}`}
+ cfg := &mockCfg{`{"address": "localhost:8080"}`}
c := &Config{}
assert.NoError(t, c.Hydrate(cfg))