-
Notifications
You must be signed in to change notification settings - Fork 66
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
Simplify the integration test code #376
Conversation
tests/integration.rs
Outdated
connection: Connection, | ||
} | ||
|
||
static mut TEST_PORT: AtomicU16 = AtomicU16::new(6479); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let use lazy static and avoid the unsafe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that it isn't relevant anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am removing the mut
and the unsafe
, so this remains a piece of code without lazy_static
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
One small comment about avoiding the unsafe block.
@MeirShpilraien, would you please review once again? |
@iddm @MeirShpilraien |
We need it just in one single file, there is no need to create a file of 20 lines of code to just fully import it later from within another file. Doesn't really contribute to the cleanliness of the code here. If at least we had two files for that, - sure. |
I agree but also I think that its a nice idea that users will be able to test their module with rust and run it with |
This isn't something specific to Redis, redismodule (this crate) or redis modules, or Rust in general. Anyone can write their own tests. But, I had already forgotten we had the |
@MeirShpilraien can you just merge it, please? |
let config_get = |config: &str| -> Result<String> { | ||
let mut con = | ||
get_redis_connection(port).with_context(|| "failed to connect to redis server")?; | ||
let config_get = |con: &mut TestConnection, config: &str| -> Result<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why the closure itself can not borrow the con here (as it was before)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think because it is mutable and would require double mutable borrow, which the borrow checker won't like.
No description provided.