func TestHash_Get(t *testing.T) { hb := redis.NewHash("users", conn) hb.Clean() hb.Insert(ins.Key(), ins) ins1 := new(Instance) err := hb.Get(ins.Key(), ins1) if err != nil { t.Errorf("Want instance got %s\n", err) } }
func TestHash_Insert(t *testing.T) { if err != nil { t.Errorf("ERROR: %s\n", err) } hb := redis.NewHash("users", conn) hb.Clean() err := hb.Insert(ins.Key(), ins) if err != nil { t.Errorf("ERROR: %s\n", err) } }
func TestHash_Update(t *testing.T) { hb := redis.NewHash("users", conn) hb.Clean() hb.Insert(ins.Key(), ins) ins.Attrs["Key"] = "user:2" hb.Update(ins.Key(), ins) if ins.Key() != "user:2" { t.Errorf("Want user:2 got %s\n", ins.Key()) } }
func TestHash_Remove(t *testing.T) { hb := redis.NewHash("users", conn) hb.Clean() hb.Insert(ins.Key(), ins) if size := hb.Size(); size != 1 { t.Errorf("Want 1 got %d\n", size) } hb.Remove(ins.Key()) if size := hb.Size(); size != 0 { t.Errorf("Want 0 got %d\n", size) } }
func TestHash_All(t *testing.T) { hb := redis.NewHash("users", conn) hb.Clean() hb.Insert("key:1", ins) hb.Insert("key:2", ins) res, err := hb.All() if err != nil { t.Errorf("ERROR: %s\n", err) } if len(res) != 2 { t.Errorf("Wany 2 got %d\n", len(res)) } }