summaryrefslogtreecommitdiff
path: root/service/env/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'service/env/config_test.go')
-rw-r--r--service/env/config_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/service/env/config_test.go b/service/env/config_test.go
new file mode 100644
index 00000000..3c943963
--- /dev/null
+++ b/service/env/config_test.go
@@ -0,0 +1,29 @@
+package env
+
+import (
+ "github.com/spiral/roadrunner/service"
+ "encoding/json"
+ "testing"
+ "github.com/stretchr/testify/assert"
+)
+
+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(t *testing.T) {
+ cfg := &mockCfg{`{"key":"value"}`}
+ c := &Config{}
+
+ assert.NoError(t, c.Hydrate(cfg))
+ assert.Len(t, c.Values, 1)
+}
+
+func Test_Config_Hydrate_Empty(t *testing.T) {
+ cfg := &mockCfg{`{}`}
+ c := &Config{}
+
+ assert.NoError(t, c.Hydrate(cfg))
+ assert.Len(t, c.Values, 0)
+} \ No newline at end of file