Closed finlaydotb closed 1 year ago
I'm a bit confused about what you are testing here. I feel like I'd need some more context. are you trying to mock your actix web implementation or some external HTTP call triggered by your actix web implementation?
let url = format!("{}/a", mocked_server.url());
let res = client
.get(&jurl)
what's jurl
in here?
let app = test::init_service(App::new().route("/", web::get().to(index))).await;
so you're calling /
here, not /a
=> I assume /a
points to an external HTTP call inside your actix web implementation then?
probably not the cause of your problem, but if you intend to write this for async, you should use the async methods everywhere, as explained here. There's also an example at the end of the Getting Started section.
So I am not 100% if I am the one not using the library right. But here is my set up
Now in a test if I do this
I do get the mocked result. But now when I run the actix web app, which calls the mocked endpoint, I get back a 501 instead. That is this does not work
Any ideas what I may be doing wrong?