You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying, to unit test my endpoints but it seems that the stuff I need for that are private. Having an example for this could be super useful for testing side-effects of your endpoints.
Here's an example of what I tried
#[test]fnendpoint_test(){let state = Arc::new(Mutex::new("hello"));// this associated function is private, doesn't compilelet http_request = tide::http::Request::new(Method::Get,Url::parse("http://0.0.0.0/play/sound2.mp3").unwrap(),);// this is private, how do I fix that?let params = vec![tide::request::Params::new()];// this is private, doesn't compilelet req = tide::Request::new(state, http_request, params);let result = my_endpoint(req);// your expected result herelet expected_result = ();assert_eq!(result, expected_result);}
I see Tide has these methods and structs public only for the crate, what would be a good way to move forward on unit tests here?
The text was updated successfully, but these errors were encountered:
I have something like fn get_info(req: &tide::Request<()>) -> InfoEnum that folks want to add tests for, but with no way to create a Request in isolation its pretty raw.
In my own project I would do a test only impl From<(tide::http::Request, State)> for tide::Request but that won't work if its inside tide itself. It would be nice to be able to write unit tests the same as within the project (ie like test/params.rs)
Hello dear Tide community ❤️
I've been trying, to unit test my endpoints but it seems that the stuff I need for that are private. Having an example for this could be super useful for testing side-effects of your endpoints.
Here's an example of what I tried
I see Tide has these methods and structs public only for the crate, what would be a good way to move forward on unit tests here?
The text was updated successfully, but these errors were encountered: