1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-29 21:57:16 +02:00
kratos/encoding/proto/proto_test.go
Kagaya f7588a47de
fix: ci lint error (#1391)
* fix lint check

* fix lll lint error

* fix build error

* fix gomnd

* fix shadow declaration

* add make test command

* update
2021-08-31 10:14:57 +08:00

37 lines
636 B
Go

package proto
import (
"testing"
"github.com/stretchr/testify/assert"
testData "github.com/go-kratos/kratos/v2/internal/testdata/encoding"
)
func TestName(t *testing.T) {
c := new(codec)
assert.Equal(t, c.Name(), "proto")
}
func TestCodec(t *testing.T) {
c := new(codec)
model := testData.TestModel{
Id: 1,
Name: "kratos",
Hobby: []string{"study", "eat", "play"},
}
m, err := c.Marshal(&model)
assert.Nil(t, err)
var res testData.TestModel
err = c.Unmarshal(m, &res)
assert.Nil(t, err)
assert.Equal(t, res.Id, model.Id)
assert.Equal(t, res.Name, model.Name)
assert.Equal(t, res.Hobby, model.Hobby)
}