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 was porting over my actix-web server to 2.0.0 and async-await and ran into this error while rewriting a test.
The code:
#[actix_rt::test]
async fn test_get_all_files() {
let test_db = test_setup("test_get_all_files", "test_files", "");
let mut app = test::init_service(
App::new()
.data(ServerGlobals::new_test(&test_db.db))
.service(web::resource("/get-all-files").to(get_files_and_folders)),
)
.await;
let resp = call_request!(app, "/get-all-files");
assert_eq!(resp.status(), http::StatusCode::OK);
let body = test::read_body(resp);
let paths: Vec<ps_database::DirEntry> = serde_json::from_slice(&body).unwrap();
let mut answers = std::collections::HashSet::new();
answers.insert(PathBuf::from("test_files/"));
answers.insert(PathBuf::from("test_files/write_file"));
answers.insert(PathBuf::from("test_files/test_original.vwxp"));
answers.insert(PathBuf::from("test_files/write_file/test_write_file.vwxp"));
for dir in paths {
dir.iterate_paths(&mut |path| {
assert!(path.is_dir() || path.extension().unwrap() == "vwxp");
answers.remove(path);
});
}
assert_eq!(answers.len(), 0);
}
I received this error message:
error[E0308]: mismatched types
|
= note: expected type `&[u8]`
found type `&impl futures::Future`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
This bug is not about the error itself, I figured out what the error is. test::read_body(resp) needs a .await after it. The issue is that the error had no line information included, so I had to go commenting out sections of code to find out which test had the error. My VSCode showed the red squiggly on the very first character of my main.rs.
The text was updated successfully, but these errors were encountered:
I was porting over my actix-web server to 2.0.0 and async-await and ran into this error while rewriting a test.
The code:
I received this error message:
This bug is not about the error itself, I figured out what the error is.
test::read_body(resp)
needs a.await
after it. The issue is that the error had no line information included, so I had to go commenting out sections of code to find out which test had the error. My VSCode showed the red squiggly on the very first character of my main.rs.The text was updated successfully, but these errors were encountered: