test(aof): add codec test

This commit is contained in:
bandl 2021-11-01 17:38:54 +08:00
parent 787003d95a
commit ce888a1d0e
1 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,21 @@
package persisted
import (
"testing"
"gitee.com/timedb/wheatCache/pkg/proto"
"github.com/stretchr/testify/require"
)
func Test_codec_Encode(t *testing.T) {
c := codec{}
req := &proto.LIndexRequest{
Key: proto.NewBaseKey("123"),
Index: 11,
}
b, err := c.Encode("LIndex", req)
require.NoError(t, err)
res, err := c.Decode(b)
require.NoError(t, err)
require.Equal(t, req.Index, res.(*proto.LIndexRequest).Index)
}