Skip to content

Commit

Permalink
fix: fix lints, failing TCs & bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
c-harish committed Dec 2, 2024
1 parent 9a9753f commit 7a36319
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion integration_tests/commands/http/geo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestGeoDist(t *testing.T) {
{Command: "GEODIST", Body: map[string]interface{}{"key": "points", "values": []interface{}{"Palermo", "Catania"}}},
{Command: "GEODIST", Body: map[string]interface{}{"key": "points", "values": []interface{}{"Palermo", "Catania", "km"}}},
},
expected: []interface{}{float64(1), float64(1), float64(166274.144), float64(166.2741)},
expected: []interface{}{float64(1), float64(1), float64(166274.1516), float64(166.2742)},
},
}

Expand Down
6 changes: 3 additions & 3 deletions integration_tests/commands/http/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ func runIntegrationTests(t *testing.T, exec *HTTPCommandExecutor, testCases []In
out := tc.expected[i]
result, _ := exec.FireCommand(cmd)

fmt.Println(cmd, result, out)
fmt.Printf("Type of value: %T\n", result) // Replace `value` with your actual variable
fmt.Printf("Type of value: %T\n", out) // Replace `value` with your actual variable
// fmt.Println(cmd, result, out)
// fmt.Printf("Type of value: %T\n", result) // Replace `value` with your actual variable
// fmt.Printf("Type of value: %T\n", out) // Replace `value` with your actual variable

switch tc.assertType[i] {
case "equal":
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/commands/resp/geo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestGeoDist(t *testing.T) {
"GEODIST points Palermo Catania",
"GEODIST points Palermo Catania km",
},
expect: []interface{}{int64(1), int64(1), "166274.144", "166.2741"},
expect: []interface{}{int64(1), int64(1), "166274.1516", "166.2742"},
},
}

Expand Down
2 changes: 1 addition & 1 deletion integration_tests/commands/websocket/geo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestGeoDist(t *testing.T) {
"GEODIST points Palermo Catania",
"GEODIST points Palermo Catania km",
},
expect: []interface{}{float64(1), float64(1), float64(166274.144), float64(166.2741)},
expect: []interface{}{float64(1), float64(1), float64(166274.1516), float64(166.2742)},
},
}

Expand Down
1 change: 0 additions & 1 deletion internal/clientio/resp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func TestSimpleStringDecode(t *testing.T) {
if v != value {
t.Fail()
}
fmt.Println(v, value)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/eval/bytearray.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func ByteSliceToObj(store *dstore.Store, oldObj *object.Obj, b []byte, objType u
func ByteSliceToIntObj(store *dstore.Store, oldObj *object.Obj, b []byte) (*object.Obj, error) {
intVal, err := strconv.ParseInt(string(b), 10, 64)
if err != nil {
return store.NewObj(string(b), -1, object.ObjTypeString, object.ObjEncodingEmbStr), nil
return store.NewObj(string(b), -1, object.ObjTypeString), nil
}
return store.NewObj(intVal, -1, object.ObjTypeInt), nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/eval/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9256,7 +9256,7 @@ func testEvalGEORADIUSBYMEMBER(t *testing.T, store *dstore.Store) {
},
"GEORADIUSBYMEMBER wrong type operation": {
setup: func() {
store.Put("wrongtype", store.NewObj("string_value", -1, object.ObjTypeString, object.ObjEncodingRaw))
store.Put("wrongtype", store.NewObj("string_value", -1, object.ObjTypeString))
},
input: []string{"wrongtype", "wtc one", "7", "km"},
migratedOutput: EvalResponse{
Expand Down
4 changes: 2 additions & 2 deletions internal/eval/geo/geo.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func Area(centerHash, radius float64) (result [9]uint64, steps uint8) {
steps = geohashEstimateStepsByRadius(radius, centerLat)
centerRadiusHash := encodeHash(centerLon, centerLat, steps)

neighbors := geohashNeighbors(uint64(centerRadiusHash), steps)
neighbors := geohashNeighbors(centerRadiusHash, steps)
area := areaBySteps(centerRadiusHash, steps)

/* Check if the step is enough at the limits of the covered area.
Expand Down Expand Up @@ -290,7 +290,7 @@ func Area(centerHash, radius float64) (result [9]uint64, steps uint8) {

// HashMinMax returns the min and max hashes for a given hash and steps. This can be used to get the range of hashes
// that a given hash and a radius (steps) will cover.
func HashMinMax(hash uint64, steps uint8) (minHash uint64, maxHash uint64) {
func HashMinMax(hash uint64, steps uint8) (minHash, maxHash uint64) {
minHash = align52Bits(hash, steps)
hash++
maxHash = align52Bits(hash, steps)
Expand Down
1 change: 0 additions & 1 deletion internal/eval/sortedset/sorted_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ func (ss *Set) CountInRange(minVal, maxVal float64) int {
// GetScoreRange returns a slice of members with scores between min and max, inclusive.
// If withScores is true, the members will be returned with their scores.
func (ss *Set) GetMemberScoresInRange(minScore, maxScore float64, count, maxCount int) (members []string, scores []float64) {

iterFunc := func(item btree.Item) bool {
ssi := item.(*Item)
if ssi.Score < minScore {
Expand Down
2 changes: 1 addition & 1 deletion internal/eval/store_eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -7035,7 +7035,7 @@ func evalGEORADIUSBYMEMBER(args []string, store *dstore.Store) *EvalResponse {
member := []interface{}{}
member = append(member, members[indices[i]])
if opts.WithDist {
member = append(member, dists[indices[i]])
member = append(member, utils.RoundToDecimals(dists[indices[i]], 4))
}
if opts.WithHash {
member = append(member, hashes[indices[i]])
Expand Down
4 changes: 2 additions & 2 deletions internal/server/cmd_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,11 @@ var (
Type: SingleShard,
}
geoRadiusByMemberCmdMeta = CmdMeta{
Cmd: "GEORADIUSBYMEMBER",
Cmd: "GEORADIUSBYMEMBER",
Type: SingleShard,
}
clientCmdMeta = CmdMeta{
Cmd: "CLIENT",
Cmd: "CLIENT",
Type: SingleShard,
}
latencyCmdMeta = CmdMeta{
Expand Down

0 comments on commit 7a36319

Please sign in to comment.