github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/pingcap/go-themis/mutation_cache_test.go (about) 1 package themis 2 3 import ( 4 "bytes" 5 6 "github.com/insionng/yougam/libraries/ngaut/log" 7 . "github.com/insionng/yougam/libraries/pingcap/check" 8 "github.com/insionng/yougam/libraries/pingcap/go-hbase" 9 ) 10 11 type MutationCacheTestSuit struct{} 12 13 var _ = Suite(&MutationCacheTestSuit{}) 14 15 func (s *MutationCacheTestSuit) TestMutationCache(c *C) { 16 cache := newColumnMutationCache() 17 row := []byte("r1") 18 col := &hbase.Column{[]byte("f1"), []byte("q1")} 19 cache.addMutation([]byte("tbl"), row, col, hbase.TypePut, []byte("test"), false) 20 cache.addMutation([]byte("tbl"), row, col, hbase.TypeDeleteColumn, []byte("test"), false) 21 cache.addMutation([]byte("tbl"), row, col, hbase.TypePut, []byte("test"), false) 22 23 cc := &hbase.ColumnCoordinate{ 24 Table: []byte("tbl"), 25 Row: []byte("r1"), 26 Column: hbase.Column{ 27 Family: []byte("f1"), 28 Qual: []byte("q1"), 29 }, 30 } 31 mutation := cache.getMutation(cc) 32 if mutation == nil || mutation.typ != hbase.TypePut || bytes.Compare(mutation.value, []byte("test")) != 0 { 33 c.Error("cache error") 34 } else { 35 log.Info(mutation) 36 } 37 38 p := hbase.NewPut([]byte("row")) 39 p.AddStringValue("cf", "q", "v") 40 p.AddStringValue("cf", "q1", "v") 41 p.AddStringValue("cf", "q2", "v") 42 p.AddStringValue("cf", "q3", "v") 43 44 entries := getEntriesFromPut(p) 45 c.Assert(len(entries), Equals, 4) 46 }