diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | service/metrics/config_test.go | 27 |
3 files changed, 30 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml index fb1873e3..fdd4e716 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ script: - go test ./service/static -race -v -coverprofile=static.txt -covermode=atomic - go test ./service/limit -race -v -coverprofile=limit.txt -covermode=atomic - go test ./service/headers -race -v -coverprofile=headers.txt -covermode=atomic + - go test ./service/metrics -race -v -coverprofile=metrics.txt -covermode=atomic after_success: - bash <(curl -s https://codecov.io/bash) -f lib.txt @@ -36,6 +37,7 @@ after_success: - bash <(curl -s https://codecov.io/bash) -f static.txt - bash <(curl -s https://codecov.io/bash) -f limit.txt - bash <(curl -s https://codecov.io/bash) -f headers.txt + - bash <(curl -s https://codecov.io/bash) -f metrics.txt jobs: include: @@ -19,3 +19,4 @@ test: go test -v -race -cover ./service/static go test -v -race -cover ./service/limit go test -v -race -cover ./service/headers + go test -v -race -cover ./service/metrics diff --git a/service/metrics/config_test.go b/service/metrics/config_test.go new file mode 100644 index 00000000..bd02d1cf --- /dev/null +++ b/service/metrics/config_test.go @@ -0,0 +1,27 @@ +package metrics + +import ( + "encoding/json" + "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 Test_Config_Hydrate_Error1(t *testing.T) { + cfg := &mockCfg{`{"request": {"From": "Something"}}`} + c := &Config{} + + assert.NoError(t, c.Hydrate(cfg)) +} + +func Test_Config_Hydrate_Error2(t *testing.T) { + cfg := &mockCfg{`{"dir": "/dir/"`} + c := &Config{} + + assert.Error(t, c.Hydrate(cfg)) +} |