summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/http/config.go12
-rw-r--r--service/http/service_test.go23
2 files changed, 17 insertions, 18 deletions
diff --git a/service/http/config.go b/service/http/config.go
index 26cede37..b11d807c 100644
--- a/service/http/config.go
+++ b/service/http/config.go
@@ -50,6 +50,18 @@ func (c *Config) Hydrate(cfg service.Config) error {
// Valid validates the configuration.
func (c *Config) Valid() error {
+ if c.Uploads == nil {
+ return errors.New("mailformed uploads config")
+ }
+
+ if c.Workers == nil {
+ return errors.New("mailformed workers config")
+ }
+
+ if c.Workers.Pool == nil {
+ return errors.New("mailformed workers config (pool config is missing)")
+ }
+
if err := c.Workers.Pool.Valid(); err != nil {
return err
}
diff --git a/service/http/service_test.go b/service/http/service_test.go
index 03a2b9a5..d1d601dc 100644
--- a/service/http/service_test.go
+++ b/service/http/service_test.go
@@ -25,6 +25,10 @@ type testCfg struct {
func (cfg *testCfg) Get(name string) service.Config {
if name == ID {
+ if cfg.httpCfg == "" {
+ return nil
+ }
+
return &testCfg{target: cfg.httpCfg}
}
@@ -63,24 +67,7 @@ func Test_Service_Configure_Disable(t *testing.T) {
c := service.NewContainer(logger)
c.Register(ID, &Service{})
- assert.NoError(t, c.Init(&testCfg{httpCfg: `{
- "enable": false,
- "address": ":8070",
- "maxRequest": 1024,
- "uploads": {
- "dir": ` + tmpDir() + `,
- "forbid": []
- },
- "workers":{
- "command": "php ../../tests/http/client.php echo pipes",
- "relay": "pipes",
- "pool": {
- "numWorkers": 1,
- "allocateTimeout": 10000000,
- "destroyTimeout": 10000000
- }
- }
- }`}))
+ assert.NoError(t, c.Init(&testCfg{}))
s, st := c.Get(ID)
assert.NotNil(t, s)