redismodule-rs icon indicating copy to clipboard operation
redismodule-rs copied to clipboard

Using RedisString::create(....) and running cargo test throws panicked at 'called `Option::unwrap()` on a `None` value

Open danitseitlin opened this issue 2 years ago • 5 comments

Hi, I've upgraded my module to redismodule-rs 0.26.0. When upgrading I had to make changes and use RedisString::create(...) function. When I ran cargo build the build passed. When I ran cargo test --features test --all --all-targets --verbose the following error appeared on each test that used RedisString:create(...):

---- get_sets_single stdout ----
thread 'get_sets_single' panicked at 'called `Option::unwrap()` on a `None` value', /home/danitseitlin/.cargo/registry/src/github.com-1ecc6299db9ec823/redis-module-0.26.0/src/redismodule.rs:107:60

Here is an example for the test:

#[test]
fn get_sets_single() {
    let ctx = Context::dummy().ctx;
    let args = vec![RedisString::create(ctx, "member1"), RedisString::create(ctx, "10"), RedisString::create(ctx, "20")];
    let sets = get_sets(args.into_iter());
    let sets = sets.expect("one member");
    assert_eq!(
        sets.0,
        vec![Set {
            member: "member1".to_string(),
            min_score: 10,
            max_score: 20,
        }]
    );
}

I hope you can help, thanks ✌🏽

danitseitlin avatar Feb 10 '22 20:02 danitseitlin

@danitseitlin do you have such branch that you migrated to 0.26?

gkorland avatar Feb 13 '22 06:02 gkorland

@danitseitlin Maybe init of redis module APIs is not done since redis-server is not launched? See this example

oshadmi avatar Feb 13 '22 07:02 oshadmi

@oshadmi The following tests are unit tests, would your suggestion still be relevant?

danitseitlin avatar Feb 13 '22 07:02 danitseitlin

@gkorland Yes, here is the ongoing PR and the branch

danitseitlin avatar Feb 13 '22 07:02 danitseitlin

@oshadmi @gkorland Hi, is there an progress with the issue?

danitseitlin avatar Feb 16 '22 22:02 danitseitlin