blob: 4ba08a04f7e8e1ff1fd51629c391518d99cf7636 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package beanstalk
import (
json "github.com/json-iterator/go"
"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 TestConfig_Hydrate_Error(t *testing.T) {
cfg := &mockCfg{`{"dead`}
c := &Config{}
assert.Error(t, c.Hydrate(cfg))
}
func TestConfig_Hydrate_Error2(t *testing.T) {
cfg := &mockCfg{`{"addr":""}`}
c := &Config{}
assert.Error(t, c.Hydrate(cfg))
}
func TestConfig_Hydrate_Error3(t *testing.T) {
cfg := &mockCfg{`{"addr":"tcp"}`}
c := &Config{}
assert.NoError(t, c.Hydrate(cfg))
_, err := c.newConn()
assert.Error(t, err)
}
func TestConfig_Hydrate_Error4(t *testing.T) {
cfg := &mockCfg{`{"addr":"unix://sock.bean"}`}
c := &Config{}
assert.NoError(t, c.Hydrate(cfg))
_, err := c.newConn()
assert.Error(t, err)
}
|