1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-28 03:57:02 +02:00
kratos/config/options_test.go
longxboy e1228d454a
support expand config keys (#1224)
* support expand config keys

* fix bytes in convertMap
2021-07-21 23:09:34 +08:00

38 lines
744 B
Go

package config
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestDefaultDecoder(t *testing.T) {
src := &KeyValue{
Key: "service",
Value: []byte("config"),
Format: "",
}
target := make(map[string]interface{}, 0)
err := defaultDecoder(src, target)
assert.Nil(t, err)
assert.Equal(t, map[string]interface{}{
"service": []byte("config"),
}, target)
src = &KeyValue{
Key: "service.name.alias",
Value: []byte("2233"),
Format: "",
}
target = make(map[string]interface{}, 0)
err = defaultDecoder(src, target)
assert.Nil(t, err)
assert.Equal(t, map[string]interface{}{
"service": map[string]interface{}{
"name": map[string]interface{}{
"alias": []byte("2233"),
},
},
}, target)
}