Skip to content

Commit e39fae8

Browse files
committed
more tests
1 parent 6508bd2 commit e39fae8

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ script:
2525
- go test ./service/static -race -v -coverprofile=static.txt -covermode=atomic
2626
- go test ./service/limit -race -v -coverprofile=limit.txt -covermode=atomic
2727
- go test ./service/headers -race -v -coverprofile=headers.txt -covermode=atomic
28+
- go test ./service/metrics -race -v -coverprofile=metrics.txt -covermode=atomic
2829

2930
after_success:
3031
- bash <(curl -s https://codecov.io/bash) -f lib.txt
@@ -36,6 +37,7 @@ after_success:
3637
- bash <(curl -s https://codecov.io/bash) -f static.txt
3738
- bash <(curl -s https://codecov.io/bash) -f limit.txt
3839
- bash <(curl -s https://codecov.io/bash) -f headers.txt
40+
- bash <(curl -s https://codecov.io/bash) -f metrics.txt
3941

4042
jobs:
4143
include:

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ test:
1919
go test -v -race -cover ./service/static
2020
go test -v -race -cover ./service/limit
2121
go test -v -race -cover ./service/headers
22+
go test -v -race -cover ./service/metrics

service/metrics/config_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package metrics
2+
3+
import (
4+
"encoding/json"
5+
"github.com/spiral/roadrunner/service"
6+
"github.com/stretchr/testify/assert"
7+
"testing"
8+
)
9+
10+
type mockCfg struct{ cfg string }
11+
12+
func (cfg *mockCfg) Get(name string) service.Config { return nil }
13+
func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) }
14+
15+
func Test_Config_Hydrate_Error1(t *testing.T) {
16+
cfg := &mockCfg{`{"request": {"From": "Something"}}`}
17+
c := &Config{}
18+
19+
assert.NoError(t, c.Hydrate(cfg))
20+
}
21+
22+
func Test_Config_Hydrate_Error2(t *testing.T) {
23+
cfg := &mockCfg{`{"dir": "/dir/"`}
24+
c := &Config{}
25+
26+
assert.Error(t, c.Hydrate(cfg))
27+
}

0 commit comments

Comments
 (0)