blob: 3c943963a846a19734d81c1818e56be33e8d73f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package env
import (
"github.com/spiral/roadrunner/service"
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
)
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(t *testing.T) {
cfg := &mockCfg{`{"key":"value"}`}
c := &Config{}
assert.NoError(t, c.Hydrate(cfg))
assert.Len(t, c.Values, 1)
}
func Test_Config_Hydrate_Empty(t *testing.T) {
cfg := &mockCfg{`{}`}
c := &Config{}
assert.NoError(t, c.Hydrate(cfg))
assert.Len(t, c.Values, 0)
}
|