Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 281 v5 sadd srem return value #293

Closed

Conversation

CoderMiguel
Copy link

attempting to fix #281

@@ -8,7 +8,7 @@
@redises.set(key, '')
expect do
@redises.send(method, *args)
end.to raise_error(defined?(default_error) ? default_error : RuntimeError)
end.to raise_error(defined?(default_error) ? default_error : Redis::BaseError)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the version 5 BaseError now inherits from StandardError instead of RuntimeError, it felt more appropriate to narrow the scope of this test to Redis::BaseError. This prevents needing to test the version and also limits the tests from passing on a different StandardError or RuntimeError.

Comment on lines -24 to -28
it 'stringifies member' do
@redises.sadd(@key, '1')
expect(@redises.srem(@key, 1)).to eq(true)
end

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to the version specific block

Comment on lines 82 to 86
def size_after(obj, &blk)
size_before = obj.size
yield
(obj.size - size_before).abs
end
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this just felt like it cleaned up the tests a little, happy to revert if the abstraction is undesired.

Gemfile Outdated

# TODO: gems added for development, remove before merge
# gem 'pry'
gem 'redis', '>= 5.0.0'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

force the tests to run in version 5

@@ -125,14 +119,13 @@ def srandmember(key, count = nil)
end

def srem(key, members)
members = Array(members).map(&:to_s)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mimicing the behavior from sadd

expect(@redises.sadd(@key, 1)).to eq(true)
end
context "adapts to redis-rd version 4 and 5 outputs" do
include MockRedis::UtilityMethods
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just trying to reuse the redis_gem_v5? method

@sds
Copy link
Owner

sds commented Jan 15, 2024

Hey @CoderMiguel, thanks for your effort on this.

As mentioned in this comment, very supportive of dropping support for redis-rb < 5 if it makes it easier for us to move forward here. Looking at the changelog going from 4 → 5, it seems pretty trivial to migrate, and 5.0.0 was released over 1.5 years ago. Would absolutely be in favor of requiring 5.0+ and removing any code specific to 4.x. Thanks!

If you rebase this PR on top of the latest main branch, the CI linting should be fixed now.

CoderMiguel added a commit to CoderMiguel/mock_redis that referenced this pull request Jan 16, 2024
@CoderMiguel CoderMiguel force-pushed the issue_281_v5_sadd_srem_return_value branch from f8faef2 to 6da7580 Compare January 16, 2024 13:56
@CoderMiguel
Copy link
Author

@sds this should be rebased now, I will revisit soon to look into the test failures and remove the version checking code I added for testing some things out.

@sds
Copy link
Owner

sds commented Sep 13, 2024

Going to close due to staleness. Feel free to reopen when you're ready to pursue again! Thank you.

@sds sds closed this Sep 13, 2024
@Palladinium
Copy link
Contributor

@CoderMiguel Are you looking to continue work on this PR? I'm looking to add support for lmpop, which was only added in redis-rb v5. I'm happy to pick up the branch myself if you can't.

@Palladinium Palladinium mentioned this pull request Nov 14, 2024
sds pushed a commit that referenced this pull request Nov 27, 2024
Currently failing due to needing redis-rb v5 (see also #281 and #293)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

From redis-rb 5.0.0, sadd and srem always return integers
3 participants