Skip to content

Commit

Permalink
chore: update rust
Browse files Browse the repository at this point in the history
  • Loading branch information
helio-frota authored and ctron committed Dec 13, 2024
1 parent 7c2c140 commit 7779927
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 38 deletions.
1 change: 1 addition & 0 deletions common/infrastructure/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct AppOptions {
}

/// create a new authenticator
#[allow(clippy::type_complexity)]
pub fn new_auth(
auth: Option<Arc<Authenticator>>,
) -> Condition<
Expand Down
2 changes: 1 addition & 1 deletion common/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl<'de> Deserialize<'de> for Id {

struct IdVisitor;

impl<'de> Visitor<'de> for IdVisitor {
impl Visitor<'_> for IdVisitor {
type Value = Id;

fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
Expand Down
3 changes: 2 additions & 1 deletion common/src/package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ mod tests {
assert_eq!(0, claimants.len());

let claimants = assertions.affected_claimants_for_version("1.3")?;
Ok(assert_eq!(1, claimants.len()))
assert_eq!(1, claimants.len());
Ok(())
}
}
26 changes: 14 additions & 12 deletions common/src/purl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<'de> Deserialize<'de> for Purl {

struct PurlVisitor;

impl<'de> Visitor<'de> for PurlVisitor {
impl Visitor<'_> for PurlVisitor {
type Value = Purl;

fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
Expand Down Expand Up @@ -241,10 +241,8 @@ mod tests {
let purl: Purl = "pkg:maven/io.quarkus/[email protected]?foo=bar".try_into()?;
let json = serde_json::to_string(&purl).unwrap();

Ok(assert_eq!(
json,
r#""pkg:maven/io.quarkus/[email protected]?foo=bar""#
))
assert_eq!(json, r#""pkg:maven/io.quarkus/[email protected]?foo=bar""#);
Ok(())
}

#[test(tokio::test)]
Expand Down Expand Up @@ -277,10 +275,11 @@ mod tests {
let purl: Purl = "pkg:oci/ose-cluster-network-operator@sha256:0170ba5eebd557fd9f477d915bb7e0d4c1ad6cd4c1852d4b1ceed7a2817dd5d2?repository_url=registry.redhat.io/openshift4/ose-cluster-network-operator&tag=v4.11.0-202403090037.p0.g33da9fb.assembly.stream.el8".try_into()?;
let json = serde_json::to_string(&purl).unwrap();

Ok(assert_eq!(
assert_eq!(
json,
r#""pkg:oci/ose-cluster-network-operator@sha256:0170ba5eebd557fd9f477d915bb7e0d4c1ad6cd4c1852d4b1ceed7a2817dd5d2?repository_url=registry.redhat.io/openshift4/ose-cluster-network-operator&tag=v4.11.0-202403090037.p0.g33da9fb.assembly.stream.el8""#
))
);
Ok(())
}

#[test(tokio::test)]
Expand All @@ -300,10 +299,11 @@ mod tests {
let purl: Purl = "pkg:rpm/redhat/[email protected]?arch=aarch64".try_into()?;
let json = serde_json::to_string(&purl).unwrap();

Ok(assert_eq!(
assert_eq!(
json,
r#""pkg:rpm/redhat/[email protected]?arch=aarch64""#
))
);
Ok(())
}

#[test(tokio::test)]
Expand Down Expand Up @@ -333,10 +333,11 @@ mod tests {
.try_into()?;
let json = serde_json::to_string(&purl).unwrap();

Ok(assert_eq!(
assert_eq!(
json,
r#""pkg:rpm/redhat/[email protected]_6?arch=s390x""#
))
);
Ok(())
}

#[test(tokio::test)]
Expand All @@ -353,6 +354,7 @@ mod tests {
"#,
)
.unwrap();
Ok(assert_eq!(purl1, purl2))
assert_eq!(purl1, purl2);
Ok(())
}
}
2 changes: 1 addition & 1 deletion entity/src/labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub mod prefixed {
prefix: &'p str,
}

impl<'p, 'de> Visitor<'de> for PrefixLabelsVisitor<'p> {
impl<'de> Visitor<'de> for PrefixLabelsVisitor<'_> {
type Value = Labels;

fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
Expand Down
28 changes: 19 additions & 9 deletions modules/analysis/src/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ mod test {
response["items"][0]["ancestors"][0]["purl"],
"pkg:rpm/redhat/[email protected]?arch=src"
);
Ok(assert_eq!(&response["total"], 1))

assert_eq!(&response["total"], 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand All @@ -227,7 +229,8 @@ mod test {
response["items"][0]["ancestors"][0]["purl"],
"pkg:rpm/redhat/[email protected]?arch=src"
);
Ok(assert_eq!(&response["total"], 1))
assert_eq!(&response["total"], 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand All @@ -249,7 +252,8 @@ mod test {
response["items"][0]["ancestors"][0]["purl"],
"pkg:rpm/redhat/[email protected]?arch=src"
);
Ok(assert_eq!(&response["total"], 1))
assert_eq!(&response["total"], 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand Down Expand Up @@ -283,7 +287,8 @@ mod test {
"pkg:maven/com.redhat.quarkus.platform/[email protected]?type=pom&repository_url=https://maven.repository.redhat.com/ga/"
);

Ok(assert_eq!(&response["total"], 2))
assert_eq!(&response["total"], 2);
Ok(())
}

// TODO: this test passes when run individually.
Expand Down Expand Up @@ -342,7 +347,8 @@ mod test {
"pkg:rpm/redhat/[email protected]"
);

Ok(assert_eq!(&response["total"], 3))
assert_eq!(&response["total"], 3);
Ok(())
}

#[test_context(TrustifyContext)]
Expand All @@ -369,7 +375,8 @@ mod test {
"pkg:rpm/redhat/[email protected]"
);

Ok(assert_eq!(&response["total"], 1))
assert_eq!(&response["total"], 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand All @@ -391,7 +398,8 @@ mod test {
response["items"][0]["deps"][0]["purl"],
"pkg:rpm/redhat/[email protected]"
);
Ok(assert_eq!(&response["total"], 1))
assert_eq!(&response["total"], 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand All @@ -414,7 +422,8 @@ mod test {
response["items"][0]["purl"],
"pkg:maven/net.spy/[email protected]?type=jar"
);
Ok(assert_eq!(&response["total"], 2))
assert_eq!(&response["total"], 2);
Ok(())
}

#[test_context(TrustifyContext)]
Expand Down Expand Up @@ -464,6 +473,7 @@ mod test {
let request: Request = TestRequest::get().uri(uri).to_request();
let response: Value = app.call_and_read_body_json(request).await;

Ok(assert_eq!(&response["total"], 0))
assert_eq!(&response["total"], 0);
Ok(())
}
}
36 changes: 24 additions & 12 deletions modules/analysis/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,8 @@ mod test {
.retrieve_root_components(Query::q("EE"), Paginated::default(), &ctx.db)
.await
.unwrap();
Ok(assert_eq!(analysis_graph.total, 1))
assert_eq!(analysis_graph.total, 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand Down Expand Up @@ -1005,7 +1006,8 @@ mod test {
.retrieve_root_components(Query::q("EE"), Paginated::default(), &ctx.db)
.await
.unwrap();
Ok(assert_eq!(analysis_graph.total, 1))
assert_eq!(analysis_graph.total, 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand Down Expand Up @@ -1044,7 +1046,8 @@ mod test {
.node_id,
"SPDXRef-A".to_string()
);
Ok(assert_eq!(analysis_graph.total, 1))
assert_eq!(analysis_graph.total, 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand Down Expand Up @@ -1085,7 +1088,8 @@ mod test {
.node_id,
"SPDXRef-A".to_string()
);
Ok(assert_eq!(analysis_graph.total, 1))
assert_eq!(analysis_graph.total, 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand Down Expand Up @@ -1119,7 +1123,8 @@ mod test {
"SPDXRef-e24fec28-1001-499c-827f-2e2e5f2671b5".to_string()
);

Ok(assert_eq!(analysis_graph.total, 2))
assert_eq!(analysis_graph.total, 2);
Ok(())
}

// TODO: this test passes when run individually.
Expand Down Expand Up @@ -1171,7 +1176,8 @@ mod test {
.retrieve_root_components(Query::q("EE"), Paginated::default(), &ctx.db)
.await
.unwrap();
Ok(assert_eq!(analysis_graph.total, 1))
assert_eq!(analysis_graph.total, 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand All @@ -1195,7 +1201,8 @@ mod test {
.retrieve_root_components(Query::q("EE"), Paginated::default(), &ctx.db)
.await
.unwrap();
Ok(assert_eq!(analysis_graph.total, 1))
assert_eq!(analysis_graph.total, 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand All @@ -1214,7 +1221,8 @@ mod test {
analysis_graph.items[0].purl,
"pkg:rpm/redhat/[email protected]?arch=src".to_string()
);
Ok(assert_eq!(analysis_graph.total, 1))
assert_eq!(analysis_graph.total, 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand All @@ -1237,7 +1245,8 @@ mod test {
"pkg:rpm/redhat/[email protected]?arch=src".to_string()
);

Ok(assert_eq!(analysis_graph.total, 1))
assert_eq!(analysis_graph.total, 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand All @@ -1256,7 +1265,8 @@ mod test {
.await
.unwrap();

Ok(assert_eq!(analysis_graph.total, 2))
assert_eq!(analysis_graph.total, 2);
Ok(())
}

#[test_context(TrustifyContext)]
Expand All @@ -1274,7 +1284,8 @@ mod test {
.await
.unwrap();

Ok(assert_eq!(analysis_graph.total, 1))
assert_eq!(analysis_graph.total, 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand All @@ -1289,7 +1300,8 @@ mod test {
.await
.unwrap();

Ok(assert_eq!(analysis_graph.total, 1))
assert_eq!(analysis_graph.total, 1);
Ok(())
}

#[test_context(TrustifyContext)]
Expand Down
2 changes: 1 addition & 1 deletion modules/fundamental/src/sbom/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<'a> From<&'a str> for SbomPackageReference<'a> {
}
}

impl<'a> From<()> for SbomPackageReference<'a> {
impl From<()> for SbomPackageReference<'_> {
fn from(_value: ()) -> Self {
Self::All
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.82.0"
channel = "1.83.0"
components = [ "rustfmt", "clippy" ]

0 comments on commit 7779927

Please sign in to comment.