Skip to content

#[proptest] Attribute Macro #153

Open
@davidbarsky

Description

@davidbarsky

Hi! I wrote a kinda rough implemenation of a #[proptest] attribute macro in awslabs/aws-lambda-rust-runtime#111. It accepts an impl Strategy<Value = T>, and I wanted to see if there's interest in me sending a pull request to introduce it here. It looks a bit like this:

pub fn gen_function_arn() -> impl Strategy<Value = FunctionArn> {
    let expr = "arn:aws:lambda:us-east-1:[0-9]{12}:function:custom-runtime";
    let arn = string_regex(expr).unwrap();
    arn.prop_map(FunctionArn)
}

#[proptest(gen_function_arn())]
fn function_arn(arn: FunctionArn) {
    let mut headers = HeaderMap::new();
    headers.typed_insert(arn.clone());
    prop_assert_eq!(headers.typed_get::<FunctionArn>(), Some(arn));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestThis issue is requesting new functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions