TestRedisClient_HashOperations tests HSet, HGet, HGetAll, HDel
(t *testing.T)
| 242 | |
| 243 | // TestRedisClient_HashOperations tests HSet, HGet, HGetAll, HDel |
| 244 | func TestRedisClient_HashOperations(t *testing.T) { |
| 245 | skipIfNoRedis(t) |
| 246 | client := GetDefaultRedisClient("redis://localhost:6379/0") |
| 247 | key := "test_hash_key" |
| 248 | client.Del(key) |
| 249 | err := client.HSet(key, "field1", "value1") |
| 250 | if err != nil { |
| 251 | t.Errorf("HSet failed: %v", err) |
| 252 | } |
| 253 | val, err := client.HGet(key, "field1") |
| 254 | if err != nil { |
| 255 | t.Errorf("HGet failed: %v", err) |
| 256 | } |
| 257 | if val != "value1" { |
| 258 | t.Errorf("HGet returned wrong value: got %s, want value1", val) |
| 259 | } |
| 260 | all, err := client.HGetAll(key) |
| 261 | if err != nil { |
| 262 | t.Errorf("HGetAll failed: %v", err) |
| 263 | } |
| 264 | if all["field1"] != "value1" { |
| 265 | t.Errorf("HGetAll returned wrong value: got %s, want value1", all["field1"]) |
| 266 | } |
| 267 | _, err = client.HDel(key, "field1") |
| 268 | if err != nil { |
| 269 | t.Errorf("HDel failed: %v", err) |
| 270 | } |
| 271 | client.Del(key) |
| 272 | } |
| 273 | |
| 274 | // TestRedisClient_ListOperations tests LPush, RPush, LRange, LPop, RPop |
| 275 | func TestRedisClient_ListOperations(t *testing.T) { |
nothing calls this directly
no test coverage detected