Skip to content

Commit

Permalink
fix: format
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Sep 4, 2024
1 parent fd64253 commit 4f267e3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"words": [
"adduser",
"autoclean",
"bencoded",
"binascii",
"bincode",
"binstall",
Expand Down
5 changes: 4 additions & 1 deletion src/bin/http_health_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ async fn main() {

let url = &args[1].clone();

let client = Client::builder().timeout(Duration::from_secs(5)).build().unwrap();
let client = Client::builder()
.timeout(Duration::from_secs(5))
.build()
.unwrap();

match client.get(url).send().await {
Ok(response) => {
Expand Down
19 changes: 11 additions & 8 deletions src/bit_torrent/info_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@
//! }
//! ```
//!
//! Refer to the struct [`TorrentInfoDictionary`](crate::models::torrent_file::TorrentInfoDictionary) for more info.
//!
//! Regarding the `source` field, it is not clear was was the initial intention
//! for that field. It could be an string to identify the source of the torrent.
//! But it has been used by private trackers to identify the tracker that
Expand Down Expand Up @@ -379,13 +377,15 @@ mod tests {
}

#[test]
fn an_info_hash_can_be_created_from_a_valid_40_utf8_char_string_representing_an_hexadecimal_value() {
fn an_info_hash_can_be_created_from_a_valid_40_utf8_char_string_representing_an_hexadecimal_value(
) {
let info_hash = InfoHash::from_str("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
assert!(info_hash.is_ok());
}

#[test]
fn an_info_hash_can_not_be_created_from_a_utf8_string_representing_a_not_valid_hexadecimal_value() {
fn an_info_hash_can_not_be_created_from_a_utf8_string_representing_a_not_valid_hexadecimal_value(
) {
let info_hash = InfoHash::from_str("GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG");
assert!(info_hash.is_err());
}
Expand All @@ -405,14 +405,17 @@ mod tests {

let output = format!("{info_hash}");

assert_eq!(output, "ffffffffffffffffffffffffffffffffffffffff");
assert_eq!(output, "ffffffffffffffffffffffffffffffffffffffff"); // DevSkim: ignore DS173237
}

#[test]
fn an_info_hash_should_return_its_a_40_utf8_lowercased_char_hex_representations_as_string() {
let info_hash = InfoHash::from_str("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF").unwrap();

assert_eq!(info_hash.to_hex_string(), "ffffffffffffffffffffffffffffffffffffffff");
assert_eq!(
info_hash.to_hex_string(),
"ffffffffffffffffffffffffffffffffffffffff" // DevSkim: ignore DS173237
);
}

#[test]
Expand Down Expand Up @@ -465,14 +468,14 @@ mod tests {

assert_eq!(
json_serialized_value,
r#"{"info_hash":"ffffffffffffffffffffffffffffffffffffffff"}"#
r#"{"info_hash":"ffffffffffffffffffffffffffffffffffffffff"}"# // DevSkim: ignore DS173237
);
}

#[test]
fn an_info_hash_can_be_deserialized() {
let json = json!({
"info_hash": "ffffffffffffffffffffffffffffffffffffffff",
"info_hash": "ffffffffffffffffffffffffffffffffffffffff", // DevSkim: ignore DS173237
});

let s: ContainingInfoHash = serde_json::from_value(json).unwrap();
Expand Down

0 comments on commit 4f267e3

Please sign in to comment.