Skip to content

How to test with the lambda macro? #277

Closed
@miles-po

Description

@miles-po

How do test the lambda given the example below? According to test functions, main does not exist.

use lambda::{lambda, Context};
use serde_json::Value;

type Error = Box<dyn std::error::Error + Send + Sync + 'static>;

#[lambda]
#[tokio::main]
async fn main(event: Value, _: Context) -> Result<Value, Error> {
    Ok(event)
}

#[cfg(test)]
mod tests {
    use serde_json::json;
    use super::*;

    #[test]
    fn test_lambda_handler() {

        let payload = json!({
            "val1": true,
            "val2": 42,
            "val3": "hello"
        });

        //
        //     W H A T   G O E S   H E R E   ?
        // 

    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions