diff options
author | Wolfy-J <[email protected]> | 2019-06-26 16:48:58 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2019-06-26 16:48:58 +0300 |
commit | e39fae803ee90384fb1fa1bf3104e583f02666fa (patch) | |
tree | a348268a181620b2ab0eb894678a7ec0f9b94684 /service | |
parent | 6508bd2e670017382d5c761c53018f9f49c15ffc (diff) |
more tests
Diffstat (limited to 'service')
-rw-r--r-- | service/metrics/config_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/service/metrics/config_test.go b/service/metrics/config_test.go new file mode 100644 index 00000000..bd02d1cf --- /dev/null +++ b/service/metrics/config_test.go @@ -0,0 +1,27 @@ +package metrics + +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)) +} |