summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-13 22:13:12 +0300
committerWolfy-J <[email protected]>2018-06-13 22:13:12 +0300
commit376547add61b3900711d33f6a20f395f7d1f4aea (patch)
tree15f3c133a896ec042934611f20a7f9598cace8f3
parent426d0034ea8c07b9303b82275934c35db77398ed (diff)
more tests
-rw-r--r--service/http/service.go1
-rw-r--r--service/http/service_test.go29
2 files changed, 28 insertions, 2 deletions
diff --git a/service/http/service.go b/service/http/service.go
index dd3888d0..1823df53 100644
--- a/service/http/service.go
+++ b/service/http/service.go
@@ -40,6 +40,7 @@ func (s *Service) AddListener(l func(event int, ctx interface{})) {
// misconfiguration. Services must not be used without proper configuration pushed first.
func (s *Service) Init(cfg service.Config, c service.Container) (bool, error) {
config := &Config{}
+
if err := cfg.Unmarshal(config); err != nil {
return false, err
}
diff --git a/service/http/service_test.go b/service/http/service_test.go
index 7ade5183..27d05783 100644
--- a/service/http/service_test.go
+++ b/service/http/service_test.go
@@ -23,8 +23,7 @@ func (cfg *testCfg) Get(name string) service.Config {
return nil
}
func (cfg *testCfg) Unmarshal(out interface{}) error {
- json.Unmarshal([]byte(cfg.httpCfg), out)
- return nil
+ return json.Unmarshal([]byte(cfg.httpCfg), out)
}
func Test_Service_NoConfig(t *testing.T) {
@@ -330,6 +329,32 @@ func Test_Service_Error2(t *testing.T) {
assert.Error(t, c.Serve())
}
+func Test_Service_Error3(t *testing.T) {
+ logger, _ := test.NewNullLogger()
+ logger.SetLevel(logrus.DebugLevel)
+
+ c := service.NewContainer(logger)
+ c.Register(Name, &Service{})
+
+ assert.Error(t, c.Init(&testCfg{`{
+ "enable": true,
+ "address": ":6029",
+ "maxRequest": 1024,
+ "uploads": {
+ "dir": ` + tmpDir() + `,
+ "forbid": []
+ },
+ "workers"
+ "command": "php ../../php-src/tests/http/client.php broken pipes",
+ "relay": "pipes",
+ "pool": {
+ "numWorkers": 1,
+ "allocateTimeout": 10000000,
+ "destroyTimeout": 10000000
+ }
+ }
+ }`}))
+}
func tmpDir() string {
p := os.TempDir()