diff --git a/Cargo.lock b/Cargo.lock index 88b64d8..990e659 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1041,6 +1041,24 @@ name = "fuchsia-zircon-sys" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "function_name" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "function_name-proc-macro 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "function_name-proc-macro" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "futures" version = "0.1.29" @@ -2058,6 +2076,7 @@ dependencies = [ "diesel_migrations 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "flame 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "flamer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "function_name 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "id3 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2092,6 +2111,14 @@ name = "ppv-lite86" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "proc-macro-crate" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "proc-macro-hack" version = "0.5.11" @@ -3545,6 +3572,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum function_name 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88b2afa9b514dc3a75af6cf24d1914e1c7eb6f1b86de849147563548d5c0a0cd" +"checksum function_name-proc-macro 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6790a8d356d2f65d7972181e866b92a50a87c27d6a48cbe9dbb8be13ca784c7d" "checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" "checksum futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987" "checksum futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86" @@ -3654,6 +3683,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" "checksum png 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "247cb804bd7fc86d0c2b153d1374265e67945875720136ca8fe451f11c6aed52" "checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" +"checksum proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" "checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" "checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" diff --git a/Cargo.toml b/Cargo.toml index 304f6e4..8f7eb28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ diesel = { version = "1.4", features = ["sqlite", "r2d2"] } diesel_migrations = { version = "1.4", features = ["sqlite"] } flame = { version = "0.2.2", optional = true } flamer = { version = "0.4", optional = true } +function_name = "0.2.0" getopts = "0.2.15" id3 = "0.3" image = "0.22" diff --git a/src/service/actix/tests/api.rs b/src/service/actix/tests/api.rs index e6b72c1..af27cd2 100644 --- a/src/service/actix/tests/api.rs +++ b/src/service/actix/tests/api.rs @@ -2,6 +2,7 @@ use actix_http::Request; use actix_web::dev::*; use actix_web::test::TestRequest; use actix_web::{test, App}; +use function_name::named; use super::configure_test_app; use crate::config; @@ -55,9 +56,10 @@ fn initial_setup() -> Request { .to_request() } +#[named] #[actix_rt::test] async fn test_version() { - let app = App::new().configure(|cfg| configure_test_app(cfg, "test_version")); + let app = App::new().configure(|cfg| configure_test_app(cfg, function_name!())); let mut service = test::init_service(app).await; let req = TestRequest::get().uri("/api/version").to_request(); let resp = service.call(req).await.unwrap(); @@ -68,9 +70,10 @@ async fn test_version() { assert_eq!(response_json, dto::Version { major: 4, minor: 0 }); } +#[named] #[actix_rt::test] async fn test_initial_setup() { - let app = App::new().configure(|cfg| configure_test_app(cfg, "test_initial_setup")); + let app = App::new().configure(|cfg| configure_test_app(cfg, function_name!())); let mut service = test::init_service(app).await; { diff --git a/src/service/actix/tests/swagger.rs b/src/service/actix/tests/swagger.rs index 73f5ecd..e421ff1 100644 --- a/src/service/actix/tests/swagger.rs +++ b/src/service/actix/tests/swagger.rs @@ -1,22 +1,24 @@ use actix_web::dev::Service; use actix_web::test::TestRequest; use actix_web::{test, App}; +use function_name::named; use super::configure_test_app; +#[named] #[actix_rt::test] async fn test_swagger_index() { - let app = App::new().configure(|cfg| configure_test_app(cfg, "test_swagger_index")); + let app = App::new().configure(|cfg| configure_test_app(cfg, function_name!())); let mut service = test::init_service(app).await; let req = TestRequest::get().uri("/swagger").to_request(); let resp = service.call(req).await.unwrap(); assert!(resp.status().is_success()); } +#[named] #[actix_rt::test] async fn test_swagger_index_with_trailing_slash() { - let app = App::new() - .configure(|cfg| configure_test_app(cfg, "test_swagger_index_with_trailing_slash")); + let app = App::new().configure(|cfg| configure_test_app(cfg, function_name!())); let mut service = test::init_service(app).await; let req = TestRequest::get().uri("/swagger/").to_request(); let resp = service.call(req).await.unwrap(); diff --git a/src/service/actix/tests/web.rs b/src/service/actix/tests/web.rs index 70b7a15..1f890fe 100644 --- a/src/service/actix/tests/web.rs +++ b/src/service/actix/tests/web.rs @@ -1,12 +1,14 @@ use actix_web::dev::Service; use actix_web::test::TestRequest; use actix_web::{test, App}; +use function_name::named; use super::configure_test_app; +#[named] #[actix_rt::test] async fn test_index() { - let app = App::new().configure(|cfg| configure_test_app(cfg, "test_index")); + let app = App::new().configure(|cfg| configure_test_app(cfg, function_name!())); let mut service = test::init_service(app).await; let req = TestRequest::get().uri("/").to_request(); let resp = service.call(req).await.unwrap();