summaryrefslogtreecommitdiff
path: root/plugins/grpc/codec/codec_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/grpc/codec/codec_test.go')
-rw-r--r--plugins/grpc/codec/codec_test.go79
1 files changed, 0 insertions, 79 deletions
diff --git a/plugins/grpc/codec/codec_test.go b/plugins/grpc/codec/codec_test.go
deleted file mode 100644
index 60efb072..00000000
--- a/plugins/grpc/codec/codec_test.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package codec
-
-import (
- "testing"
-
- json "github.com/json-iterator/go"
- "github.com/stretchr/testify/assert"
-)
-
-type jsonCodec struct{}
-
-func (jsonCodec) Marshal(v interface{}) ([]byte, error) {
- return json.Marshal(v)
-}
-
-func (jsonCodec) Unmarshal(data []byte, v interface{}) error {
- return json.Unmarshal(data, v)
-}
-
-func (jsonCodec) Name() string {
- return "json"
-}
-
-func TestCodec_String(t *testing.T) {
- c := Codec{jsonCodec{}}
-
- assert.Equal(t, "raw:json", c.String())
-
- r := RawMessage{}
- r.Reset()
- r.ProtoMessage()
- assert.Equal(t, "rawMessage", r.String())
-}
-
-func TestCodec_Unmarshal_ByPass(t *testing.T) {
- c := Codec{jsonCodec{}}
-
- s := struct {
- Name string
- }{}
-
- assert.NoError(t, c.Unmarshal([]byte(`{"name":"name"}`), &s))
- assert.Equal(t, "name", s.Name)
-}
-
-func TestCodec_Marshal_ByPass(t *testing.T) {
- c := Codec{jsonCodec{}}
-
- s := struct {
- Name string
- }{
- Name: "name",
- }
-
- d, err := c.Marshal(s)
- assert.NoError(t, err)
-
- assert.Equal(t, `{"Name":"name"}`, string(d))
-}
-
-func TestCodec_Unmarshal_Raw(t *testing.T) {
- c := Codec{jsonCodec{}}
-
- s := RawMessage{}
-
- assert.NoError(t, c.Unmarshal([]byte(`{"name":"name"}`), &s))
- assert.Equal(t, `{"name":"name"}`, string(s))
-}
-
-func TestCodec_Marshal_Raw(t *testing.T) {
- c := Codec{jsonCodec{}}
-
- s := RawMessage(`{"Name":"name"}`)
-
- d, err := c.Marshal(s)
- assert.NoError(t, err)
-
- assert.Equal(t, `{"Name":"name"}`, string(d))
-}