diff --git a/Makefile b/Makefile index a7bf9c1..6ed28b3 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ COVERAGE_FLAGS=-Cinstrument-coverage -Zcoverage-options=condition snapshots: - env INSTA_UPDATE=unseen cargo test + env INSTA_UPDATE=unseen cargo test snapshot_tests snapshots-review: - cargo instal revirew + cargo instal review coverage: cargo llvm-cov --features=coverage --open diff --git a/repology-webapp/tests/integration_tests/maintainer.rs b/repology-webapp/tests/integration_tests/maintainer.rs index a132f08..2740e4d 100644 --- a/repology-webapp/tests/integration_tests/maintainer.rs +++ b/repology-webapp/tests/integration_tests/maintainer.rs @@ -9,7 +9,7 @@ use repology_webapp_test_utils::check_response; migrator = "repology_common::MIGRATOR", fixtures("common_repositories", "maintainer_data") )] -async fn test_maintainer(pool: PgPool) { +async fn test_nonexistent(pool: PgPool) { check_response!( pool, "/maintainer/nonexistent@example.com", @@ -18,6 +18,13 @@ async fn test_maintainer(pool: PgPool) { html_ok "allow_empty_tags,warnings_fatal", contains "Unknown maintainer", ); +} + +#[sqlx::test( + migrator = "repology_common::MIGRATOR", + fixtures("common_repositories", "maintainer_data") +)] +async fn test_orphaned(pool: PgPool) { check_response!( pool, "/maintainer/orphaned@example.com", @@ -26,6 +33,13 @@ async fn test_maintainer(pool: PgPool) { html_ok "allow_empty_tags,warnings_fatal", contains "Gone maintainer", ); +} + +#[sqlx::test( + migrator = "repology_common::MIGRATOR", + fixtures("common_repositories", "maintainer_data") +)] +async fn test_orphaned_in_future(pool: PgPool) { check_response!( pool, "/maintainer/orphaned-in-future@example.com", @@ -34,7 +48,13 @@ async fn test_maintainer(pool: PgPool) { html_ok "allow_empty_tags,warnings_fatal", contains "Gone maintainer", ); +} +#[sqlx::test( + migrator = "repology_common::MIGRATOR", + fixtures("common_repositories", "maintainer_data") +)] +async fn test_active(pool: PgPool) { check_response!( pool, "/maintainer/active@example.com", @@ -52,6 +72,13 @@ async fn test_maintainer(pool: PgPool) { // not testing similar maintainers for now // not testing projects list for now ); +} + +#[sqlx::test( + migrator = "repology_common::MIGRATOR", + fixtures("common_repositories", "maintainer_data") +)] +async fn test_fallback(pool: PgPool) { check_response!( pool, "/maintainer/fallback-mnt-foo@repology", @@ -63,6 +90,15 @@ async fn test_maintainer(pool: PgPool) { // contact section contains_not "mailto:active@example.com", ); +} + +#[sqlx::test( + migrator = "repology_common::MIGRATOR", + fixtures("common_repositories", "maintainer_data") +)] +async fn test_no_vuln_column(pool: PgPool) { + // Maintainer not updated for a long time, without vulnerable projects + // counter filled. check_response!( pool, "/maintainer/no-vuln-column@example.com", diff --git a/repology-webapp/tests/integration_tests/repository.rs b/repology-webapp/tests/integration_tests/repository.rs index cbd880c..2b17244 100644 --- a/repology-webapp/tests/integration_tests/repository.rs +++ b/repology-webapp/tests/integration_tests/repository.rs @@ -6,7 +6,7 @@ use sqlx::PgPool; use repology_webapp_test_utils::check_response; #[sqlx::test(migrator = "repology_common::MIGRATOR", fixtures("repository_data"))] -async fn test_repository(pool: PgPool) { +async fn test_nonexistent(pool: PgPool) { check_response!( pool, "/repository/nonexistent", @@ -16,6 +16,10 @@ async fn test_repository(pool: PgPool) { //html_ok "allow_empty_tags,warnings_fatal", //contains "Unknown repositry", ); +} + +#[sqlx::test(migrator = "repology_common::MIGRATOR", fixtures("repository_data"))] +async fn test_orphaned(pool: PgPool) { check_response!( pool, "/repository/orphaned", @@ -24,6 +28,10 @@ async fn test_repository(pool: PgPool) { html_ok "allow_empty_tags,warnings_fatal", contains "Gone repository", ); +} + +#[sqlx::test(migrator = "repology_common::MIGRATOR", fixtures("repository_data"))] +async fn test_empty(pool: PgPool) { check_response!( pool, "/repository/empty", @@ -32,6 +40,13 @@ async fn test_repository(pool: PgPool) { html_ok "allow_empty_tags,warnings_fatal", contains_not "Gone repository", ); +} + +#[sqlx::test(migrator = "repology_common::MIGRATOR", fixtures("repository_data"))] +async fn test_stripped(pool: PgPool) { + // test handling minimal data in database: empty metadata, and + // no used_package_link_types; in prod this case is possible + // for repositories removed long time ago check_response!( pool, "/repository/stripped", @@ -42,6 +57,10 @@ async fn test_repository(pool: PgPool) { contains "homepage or download links", contains "package recipes or sources", ); +} + +#[sqlx::test(migrator = "repology_common::MIGRATOR", fixtures("repository_data"))] +async fn test_normal(pool: PgPool) { check_response!( pool, "/repository/good", diff --git a/repology-webapp/tests/snapshot_tests/maintainer.rs b/repology-webapp/tests/snapshot_tests/maintainer.rs index be134cc..83a0524 100644 --- a/repology-webapp/tests/snapshot_tests/maintainer.rs +++ b/repology-webapp/tests/snapshot_tests/maintainer.rs @@ -9,11 +9,46 @@ use super::uri_snapshot_test; migrator = "repology_common::MIGRATOR", fixtures("common_repositories", "maintainer_data") )] -async fn test_maintainer(pool: PgPool) { +async fn test_nonexistent(pool: PgPool) { uri_snapshot_test(pool.clone(), "/maintainer/nonexistent@example.com").await; +} + +#[sqlx::test( + migrator = "repology_common::MIGRATOR", + fixtures("common_repositories", "maintainer_data") +)] +async fn test_orphaned(pool: PgPool) { uri_snapshot_test(pool.clone(), "/maintainer/orphaned@example.com").await; +} + +#[sqlx::test( + migrator = "repology_common::MIGRATOR", + fixtures("common_repositories", "maintainer_data") +)] +async fn test_orphaned_in_future(pool: PgPool) { uri_snapshot_test(pool.clone(), "/maintainer/orphaned-in-future@example.com").await; +} + +#[sqlx::test( + migrator = "repology_common::MIGRATOR", + fixtures("common_repositories", "maintainer_data") +)] +async fn test_active(pool: PgPool) { uri_snapshot_test(pool.clone(), "/maintainer/active@example.com").await; +} + +#[sqlx::test( + migrator = "repology_common::MIGRATOR", + fixtures("common_repositories", "maintainer_data") +)] +async fn test_fallback(pool: PgPool) { uri_snapshot_test(pool.clone(), "/maintainer/fallback-mnt-foo@repology").await; +} + +#[sqlx::test( + migrator = "repology_common::MIGRATOR", + fixtures("common_repositories", "maintainer_data") +)] +async fn test_no_vuln_column(pool: PgPool) { uri_snapshot_test(pool.clone(), "/maintainer/no-vuln-column@example.com").await; } diff --git a/repology-webapp/tests/snapshot_tests/repository.rs b/repology-webapp/tests/snapshot_tests/repository.rs index 99cf0ae..23c1109 100644 --- a/repology-webapp/tests/snapshot_tests/repository.rs +++ b/repology-webapp/tests/snapshot_tests/repository.rs @@ -6,10 +6,26 @@ use sqlx::PgPool; use super::uri_snapshot_test; #[sqlx::test(migrator = "repology_common::MIGRATOR", fixtures("repository_data"))] -async fn test_repository(pool: PgPool) { +async fn test_nonexistent(pool: PgPool) { uri_snapshot_test(pool.clone(), "/repository/nonexistent").await; +} + +#[sqlx::test(migrator = "repology_common::MIGRATOR", fixtures("repository_data"))] +async fn test_orphaned(pool: PgPool) { uri_snapshot_test(pool.clone(), "/repository/orphaned").await; +} + +#[sqlx::test(migrator = "repology_common::MIGRATOR", fixtures("repository_data"))] +async fn test_empty(pool: PgPool) { uri_snapshot_test(pool.clone(), "/repository/empty").await; +} + +#[sqlx::test(migrator = "repology_common::MIGRATOR", fixtures("repository_data"))] +async fn test_stripped(pool: PgPool) { uri_snapshot_test(pool.clone(), "/repository/stripped").await; +} + +#[sqlx::test(migrator = "repology_common::MIGRATOR", fixtures("repository_data"))] +async fn test_normal(pool: PgPool) { uri_snapshot_test(pool.clone(), "/repository/good").await; }