summaryrefslogtreecommitdiff
path: root/plugins/grpc/codec/codec_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-09-16 21:46:50 +0300
committerGitHub <[email protected]>2021-09-16 21:46:50 +0300
commit3581b45f237a3f7aa29591ceb2bf6f4a4642a2f5 (patch)
treee723b19ec1ac16b7ccc7b3c2da69d4a416d63d81 /plugins/grpc/codec/codec_test.go
parent337d292dd2d6ff0a555098b1970d8194d8df8bc2 (diff)
parent823d831b57b75f70c7c3bbbee355f2016633bb3b (diff)
[#803]: feat(plugins): move plugins to a separate repositoryv2.5.0-alpha.2
[#803]: feat(plugins): move plugins to a separate repository
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))
-}