Skip to content

Commit

Permalink
Update Hash to allow for expirey commands (#146)
Browse files Browse the repository at this point in the history
* Convert hash to composite type. Fixed broken Hash commands from Hash refactor. Coverage and fixed broken test - @osteensco
  • Loading branch information
osteensco authored Nov 3, 2024
1 parent 05b7601 commit 0964008
Show file tree
Hide file tree
Showing 8 changed files with 5,189 additions and 5,129 deletions.
9,805 changes: 4,885 additions & 4,920 deletions coverage/coverage.out

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion internal/modules/generic/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,11 @@ func handleType(params internal.HandlerFuncParams) ([]byte, error) {
case reflect.Slice:
type_string = "list"
case reflect.Map:
type_string = "hash"
if t.Elem().Name() == "HashValue" {
type_string = "hash"
} else {
type_string = t.Elem().Name()
}
case reflect.Pointer:
if t.Elem().Name() == "Set" {
type_string = "set"
Expand Down
4 changes: 2 additions & 2 deletions internal/modules/generic/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2786,7 +2786,7 @@ func Test_Generic(t *testing.T) {
}()
client := resp.NewConn(conn)

expected := "Key"
expected := "key"
if err = client.WriteArray([]resp.Value{resp.StringValue("RANDOMKEY")}); err != nil {
t.Error(err)
}
Expand All @@ -2796,7 +2796,7 @@ func Test_Generic(t *testing.T) {
t.Error(err)
}

if !strings.Contains(res.String(), expected) {
if !strings.Contains(strings.ToLower(res.String()), expected) {
t.Errorf("expected a key containing substring '%s', got %s", expected, res.String())
}
})
Expand Down
Loading

0 comments on commit 0964008

Please sign in to comment.