summaryrefslogtreecommitdiff
path: root/service/env/config_test.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-07-26 17:05:54 +0300
committerWolfy-J <[email protected]>2018-07-26 17:05:54 +0300
commit8226b1f064ba1dca8f817bb882e0e570fc057e43 (patch)
tree606261f4b57d3acc5c977f57253c848782f40952 /service/env/config_test.go
parent234995f297c4067f4dfdba305f3b16a90143cf12 (diff)
default service value as version
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