mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-30 04:31:03 +02:00
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)
|
||
|
}
|