feat/config-decode
包哲承 2 years ago
parent 000cd9170a
commit 4a90be6f9b
  1. 2
      config/config.go
  2. 10
      config/config_test.go
  3. 4
      config/reader_test.go

@ -3,11 +3,11 @@ package config
import (
"context"
"errors"
"github.com/go-kratos/kratos/v2/encoding"
"reflect"
"sync"
"time"
"github.com/go-kratos/kratos/v2/encoding"
// init encoding
_ "github.com/go-kratos/kratos/v2/encoding/json"
_ "github.com/go-kratos/kratos/v2/encoding/proto"

@ -3,6 +3,9 @@ package config
import (
"errors"
"testing"
"github.com/go-kratos/kratos/v2/encoding"
_ "github.com/go-kratos/kratos/v2/encoding/json"
)
const (
@ -128,9 +131,10 @@ func TestConfig(t *testing.T) {
jSource := newTestJSONSource(_testJSON)
opts := options{
sources: []Source{jSource},
decoder: defaultDecoder,
resolver: defaultResolver,
sources: []Source{jSource},
decoder: defaultDecoder,
resolver: defaultResolver,
mergeCodec: encoding.GetCodec("json"),
}
cf := &config{}
cf.opts = opts

@ -6,6 +6,7 @@ import (
"testing"
"github.com/go-kratos/kratos/v2/encoding"
_ "github.com/go-kratos/kratos/v2/encoding/json"
)
func TestReader_Merge(t *testing.T) {
@ -183,7 +184,8 @@ func TestReader_Source(t *testing.T) {
}
return fmt.Errorf("unsupported key: %s format: %s", kv.Key, kv.Format)
},
resolver: defaultResolver,
resolver: defaultResolver,
mergeCodec: encoding.GetCodec("json"),
}
r := newReader(opts)
err = r.Merge(&KeyValue{

Loading…
Cancel
Save