How do I pass app as a function argument? - Error: is not implemented for impl Future<Output = impl Service<..., Response = ..., Error = ...>>
#3500
Answered
by
robjtede
SamuelMarks
asked this question in
Q&A
-
|
Following your https://docs.rs/actix-web/4.9.0/src/actix_web/test/test_utils.rs.html#578 I try to make a simple service: pub(crate) async fn secret_app_get() -> impl actix_web::dev::Service<
actix_http::Request,
Response = actix_web::dev::ServiceResponse<impl actix_http::body::MessageBody>,
Error = actix_web::error::Error
> {
actix_web::test::init_service(
actix_web::App::new()
.app_data(actix_web::web::Data::new(crate::POOL.clone()))
.service(
actix_web::web::scope("/api/v0")
.wrap(actix_web::middleware::Compat::new(
actix_web_httpauth::middleware::HttpAuthentication::bearer(
crate::middleware::bearer::validator,
),
))
.service(crate::routes::secret::secret),
),
)
}And call it in a test: #[actix_web::test]
async fn test_read_secret() {
crate::tests::init_db_for_test();
let app = secret_app_get().await;
}But I get this error: |
Beta Was this translation helpful? Give feedback.
Answered by
robjtede
Jan 8, 2025
Replies: 1 comment
-
.service(crate::routes::secret::secret),
),
- )
+ ).await
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
robjtede
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.service(crate::routes::secret::secret), ), - ) + ).await }