mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-28 03:57:02 +02:00
e1228d454a
* support expand config keys * fix bytes in convertMap
38 lines
744 B
Go
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)
|
|
}
|