RawMessage support
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -4,7 +4,9 @@ import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
yamlc "github.com/goccy/go-yaml"
|
||||
"go.unistack.org/micro/v4/codec"
|
||||
utime "go.unistack.org/micro/v4/util/time"
|
||||
)
|
||||
|
||||
func TestFrame(t *testing.T) {
|
||||
@@ -52,3 +54,33 @@ func TestNativeYamlTags(t *testing.T) {
|
||||
t.Fatalf("XXX %#+v\n", s)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDuration(t *testing.T) {
|
||||
s := &struct {
|
||||
One utime.Duration `yaml:"timeout"`
|
||||
}{
|
||||
One: 0,
|
||||
}
|
||||
err := NewCodec().Unmarshal([]byte(`timeout: "5s"`), s)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if s.One != 5000000000 {
|
||||
t.Fatal("invalid duration parsed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRawMessage(t *testing.T) {
|
||||
s := &struct {
|
||||
One *yamlc.RawMessage `yaml:"one"`
|
||||
}{}
|
||||
|
||||
err := NewCodec().Unmarshal([]byte(`---
|
||||
one:
|
||||
two:
|
||||
- test`), s)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("s %s", s.One)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user