diff options
author | Wolfy-J <[email protected]> | 2018-07-08 21:57:15 -0700 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-07-08 21:57:15 -0700 |
commit | 528eb2c1b9befaac82a85de9c6d7dea86da0aaac (patch) | |
tree | 7f2afc57c7880b4cbf66fd98d857c0d03607a580 /service/rpc/config_test.go | |
parent | c691f2b3e91c00d29201f06253b845f59e66959d (diff) |
more tests
Diffstat (limited to 'service/rpc/config_test.go')
-rw-r--r-- | service/rpc/config_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/service/rpc/config_test.go b/service/rpc/config_test.go index 8642e9ab..95eb41b4 100644 --- a/service/rpc/config_test.go +++ b/service/rpc/config_test.go @@ -4,8 +4,29 @@ import ( "github.com/stretchr/testify/assert" "runtime" "testing" + "encoding/json" + "github.com/spiral/roadrunner/service" ) +type testCfg struct{ cfg string } + +func (cfg *testCfg) Get(name string) service.Config { return nil } +func (cfg *testCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } + +func Test_Config_Hydrate(t *testing.T) { + cfg := &testCfg{`{"enable": true, "listen": "tcp://:18001"}`} + c := &Config{} + + assert.NoError(t, c.Hydrate(cfg)) +} + +func Test_Config_Hydrate_Error(t *testing.T) { + cfg := &testCfg{`{"enable": true, "listen": "invalid"}`} + c := &Config{} + + assert.Error(t, c.Hydrate(cfg)) +} + func TestConfig_Listener(t *testing.T) { cfg := &Config{Listen: "tcp://:18001"} |