Skip to content

Commit

Permalink
Finalize latest-versions badge test and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Sep 12, 2024
1 parent dbdc693 commit 5faceb1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
11 changes: 2 additions & 9 deletions repology-webapp/src/views/badges/latest_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use sqlx::FromRow;

use libversion::AsVersionWithFlags;

use repology_common::{PackageFlags, PackageStatus};
use repology_common::PackageFlags;

use crate::badges::{render_generic_badge, Cell};
use crate::package::traits::{PackageWithFlags, PackageWithStatus, PackageWithVersion};
use crate::package::traits::{PackageWithFlags, PackageWithVersion};
use crate::package::version::package_version;
use crate::result::EndpointResult;
use crate::state::AppState;
Expand All @@ -29,7 +29,6 @@ pub struct QueryParams {
#[derive(FromRow)]
pub struct Package {
pub version: String,
pub status: PackageStatus,
pub flags: i32,
}

Expand All @@ -43,11 +42,6 @@ impl PackageWithFlags for Package {
PackageFlags::from_bits(self.flags as u32).expect("flags must be deserializable")
}
}
impl PackageWithStatus for Package {
fn status(&self) -> PackageStatus {
self.status
}
}

pub async fn badge_latest_versions(
Path(project_name): Path<String>,
Expand All @@ -64,7 +58,6 @@ pub async fn badge_latest_versions(
r#"
SELECT
version,
versionclass AS status,
flags
FROM packages
WHERE effname = $1 AND versionclass IN (1, 4, 5) -- Newest, Unique, Devel
Expand Down
7 changes: 7 additions & 0 deletions repology-webapp/tests/badges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ async fn test_badge_latest_versions(pool: PgPool) {
@"string(//svg:g[1]/svg:g[1]/svg:text[1])" == "latest packaged versions",
@"string(//svg:g[1]/svg:g[1]/svg:text[3])" == "3.0, 1.0.0, 1_0_0, 1.0",
);
check_svg!(
pool,
"/badge/latest-versions/bash.svg",
@"count(//svg:g[1]/svg:g[1]/svg:text)" == 4_f64,
@"string(//svg:g[1]/svg:g[1]/svg:text[1])" == "latest packaged version",
@"string(//svg:g[1]/svg:g[1]/svg:text[3])" == "1.0",
);

// caption flags
check_svg!(
Expand Down
3 changes: 2 additions & 1 deletion repology-webapp/tests/fixtures/badge_versions_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ INSERT INTO packages(effname, version, versionclass, flags, repo, family, trackn
('zsh', '1.0.0', 1, 0, '', '', '', '', '', '', '', false),
('zsh', '1.0', 1, 0, '', '', '', '', '', '', '', false),
('zsh', '2024', 2, 1 << 8, '', '', '', '', '', '', '', false), -- sink
('zsh', '2025', 3, 0, '', '', '', '', '', '', '', false); -- ignored
('zsh', '2025', 3, 0, '', '', '', '', '', '', '', false), -- ignored
('bash', '1.0', 4, 0, '', '', '', '', '', '', '', false); -- unique

0 comments on commit 5faceb1

Please sign in to comment.