util_test.go 671 B

1234567891011121314151617181920212223242526
  1. package memcache
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. pb "go-common/library/cache/memcache/test"
  6. )
  7. func TestItemUtil(t *testing.T) {
  8. item1 := RawItem("test", []byte("hh"), 0, 0)
  9. assert.Equal(t, "test", item1.Key)
  10. assert.Equal(t, []byte("hh"), item1.Value)
  11. assert.Equal(t, FlagRAW, FlagRAW&item1.Flags)
  12. item1 = JSONItem("test", &Item{}, 0, 0)
  13. assert.Equal(t, "test", item1.Key)
  14. assert.NotNil(t, item1.Object)
  15. assert.Equal(t, FlagJSON, FlagJSON&item1.Flags)
  16. item1 = ProtobufItem("test", &pb.TestItem{}, 0, 0)
  17. assert.Equal(t, "test", item1.Key)
  18. assert.NotNil(t, item1.Object)
  19. assert.Equal(t, FlagProtobuf, FlagProtobuf&item1.Flags)
  20. }