Repository: DiceDB/dice
File: integration_tests/commands/async/hincrby_test.go (Go)

Code before:
			expected: []interface{}{"ERR value is not an integer or out of range"},
		},
		{
			name:     "HINCRBY should give error when trying to increment a key which is not a hash value",
			commands: []string{"SET key value", "HINCRBY key value 10"},
			expected: []interface{}{"OK", "WRONGTYPE Operation against a key holding the wrong kind of value"},
		},
		{
			name:     "HINCRBY should give error when the increment value adds up to overflow",
			commands: []string{"HSET new-key value 9000000000000000000", "HINCRBY new-key value 1000000000000000000"},
			expected: []interface{}{int64(1), "ERR increment or decrement would overflow"},
		},
		{
			name:     "HINCRBY should give error when the value decrements to overflow",
			commands: []string{"HSET new-key value -9000000000000000000", "HINCRBY new-key value -1000000000000000000"},
			expected: []interface{}{int64(0), "ERR increment or decrement would overflow"},
		},
		{
			name:     "HINCRBY should decrement the value",
			commands: []string{"HSET new-key value 10", "HINCRBY new-key value -1"},
			expected: []interface{}{int64(0), int64(9)},
		},
		{
			name:     "HINCRBY should give integer error when trying to increment a key which is not a hash value with a value which is not integer",
			commands: []string{"SET key value", "HINCRBY key value ten"},
			expected: []interface{}{"OK", "WRONGTYPE Operation against a key holding the wrong kind of value"},
		},
	}

	for _, tc := range testcases {
		for i, cmd := range tc.commands {
			result := FireCommand(conn, cmd)
			assert.DeepEqual(t, tc.expected[i], result)
		}
	}
}


Review comment (suggestion):
Hi, Thanks for adding this test case. Please check the expected output in redis.
<img width="444" alt="image" src="https://github.com/user-attachments/assets/e4303c12-c826-4b04-9ae5-46aeda651a31">
We need to return an integer error in this case. 

Code after:
			name:     "HINCRBY should give error when increment value is not an integer",
			commands: []string{"HINCRBY key field value"},
			expected: []interface{}{"ERR value is not an integer or out of range"},
		},
		{
			name:     "HINCRBY should give error when trying to increment a key which is not a hash value",
			commands: []string{"SET key value", "HINCRBY key value 10"},
			expected: []interface{}{"OK", "WRONGTYPE Operation against a key holding the wrong kind of value"},
		},
		{
			name:     "HINCRBY should give error when the increment value adds up to overflow",
			commands: []string{"HSET new-key value 9000000000000000000", "HINCRBY new-key value 1000000000000000000"},
			expected: []interface{}{int64(1), "ERR increment or decrement would overflow"},
		},
		{
			name:     "HINCRBY should give error when the value decrements to overflow",
			commands: []string{"HSET new-key value -9000000000000000000", "HINCRBY new-key value -1000000000000000000"},
			expected: []interface{}{int64(0), "ERR increment or decrement would overflow"},
		},
		{
			name:     "HINCRBY should decrement the value",
			commands: []string{"HSET new-key value 10", "HINCRBY new-key value -1"},
			expected: []interface{}{int64(0), int64(9)},
		},
		{
			name:     "HINCRBY should give integer error when trying to increment a key which is not a hash value with a value which is not integer",
			commands: []string{"SET key value", "HINCRBY key value ten"},
			expected: []interface{}{"OK", "ERR value is not an integer or out of range"},
		},
	}

	for _, tc := range testcases {
		for i, cmd := range tc.commands {
			result := FireCommand(conn, cmd)
			assert.DeepEqual(t, tc.expected[i], result)
		}
	}
}