diff options
author | Wolfy-J <[email protected]> | 2018-09-10 15:11:55 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-09-10 15:11:55 +0300 |
commit | 5dcbd1fd465956ee377c67f3b5d5a17701af235a (patch) | |
tree | 92a649424717478487e0d9f5a51da8b6584456c0 /service | |
parent | 6f70e31df4a88b85e576789ebe4fee6b5fc12d86 (diff) |
more tests
Diffstat (limited to 'service')
-rw-r--r-- | service/env/service.go | 6 | ||||
-rw-r--r-- | service/env/service_test.go | 10 | ||||
-rw-r--r-- | service/rpc/service.go | 6 |
3 files changed, 16 insertions, 6 deletions
diff --git a/service/env/service.go b/service/env/service.go index a4d3959c..41e70bee 100644 --- a/service/env/service.go +++ b/service/env/service.go @@ -4,8 +4,8 @@ const ( // ID contains default service name. ID = "env" - // RRKey contains default env key to indicate than php running in RR mode. - RRKey = "RR" + // rrKey contains default env key to indicate than php running in RR mode. + rrKey = "rr" ) // Service provides ability to map _ENV values from config file. @@ -25,7 +25,7 @@ func NewService(defaults map[string]string) *Service { func (s *Service) Init(cfg *Config) (bool, error) { if s.values == nil { s.values = make(map[string]string) - s.values[RRKey] = "yes" + s.values[rrKey] = "yes" } for k, v := range cfg.Values { diff --git a/service/env/service_test.go b/service/env/service_test.go index 5b148207..28e0d15b 100644 --- a/service/env/service_test.go +++ b/service/env/service_test.go @@ -10,6 +10,16 @@ func Test_NewService(t *testing.T) { assert.Len(t, s.values, 1) } +func Test_Init(t *testing.T) { + s := &Service{} + s.Init(&Config{}) + assert.Len(t, s.values, 1) + + values, err := s.GetEnv() + assert.NoError(t, err) + assert.Equal(t, "yes", values["rr"]) +} + func Test_Extend(t *testing.T) { s := NewService(map[string]string{"rr": "version"}) diff --git a/service/rpc/service.go b/service/rpc/service.go index 14e34319..d8c2b9d5 100644 --- a/service/rpc/service.go +++ b/service/rpc/service.go @@ -12,9 +12,9 @@ const ( // ID contains default service name. ID = "rpc" - // RRKey defines environment key to be used to store information about + // rrKey defines environment key to be used to store information about // rpc server connection. - EnvKey = "RR_RPC" + envKey = "rr-rpc" ) // Service is RPC service. @@ -36,7 +36,7 @@ func (s *Service) Init(cfg *Config, env env.Environment) (bool, error) { s.rpc = rpc.NewServer() if env != nil { - env.SetEnv(EnvKey, cfg.Listen) + env.SetEnv(envKey, cfg.Listen) } return true, nil |