diff options
Diffstat (limited to 'plugins/broadcast/websockets/config_test.go')
-rw-r--r-- | plugins/broadcast/websockets/config_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/plugins/broadcast/websockets/config_test.go b/plugins/broadcast/websockets/config_test.go new file mode 100644 index 00000000..e646fdc4 --- /dev/null +++ b/plugins/broadcast/websockets/config_test.go @@ -0,0 +1,34 @@ +package websockets + +import ( + "encoding/json" + "testing" + + "github.com/spiral/roadrunner/service" + "github.com/stretchr/testify/assert" +) + +type mockCfg struct{ cfg string } + +func (cfg *mockCfg) Get(name string) service.Config { + if name == "same" || name == "jobs" { + return cfg + } + + return nil +} +func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } + +func Test_Config_Hydrate_Error(t *testing.T) { + cfg := &mockCfg{cfg: `{"dead`} + c := &Config{} + + assert.Error(t, c.Hydrate(cfg)) +} + +func Test_Config_Hydrate_OK(t *testing.T) { + cfg := &mockCfg{cfg: `{"path":"/path"}`} + c := &Config{} + + assert.NoError(t, c.Hydrate(cfg)) +} |