Files
micro-codec-segmentio/json/codec_test.go
Vasiliy Tolstov 08b68d26c7
All checks were successful
test / test (push) Successful in 3m15s
move to micro v4
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-03-05 22:53:03 +03:00

39 lines
692 B
Go

package json
import (
"bytes"
"testing"
"go.unistack.org/micro/v4/codec"
)
func TestFrame(t *testing.T) {
s := &codec.Frame{Data: []byte("test")}
buf, err := NewCodec().Marshal(s)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(buf, []byte(`test`)) {
t.Fatalf("bytes not equal %s != %s", buf, `test`)
}
}
func TestFrameFlatten(t *testing.T) {
s := &struct {
One string
Name *codec.Frame `json:"name" codec:"flatten"`
}{
One: "xx",
Name: &codec.Frame{Data: []byte("test")},
}
buf, err := NewCodec(codec.Flatten(true)).Marshal(s)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(buf, []byte(`test`)) {
t.Fatalf("bytes not equal %s != %s", buf, `test`)
}
}