Fix new lints

This commit is contained in:
Jonas Platte 2023-11-08 17:48:40 +01:00
parent db06702a0f
commit c82f600d6a
No known key found for this signature in database
GPG key ID: AAA7A61F696C3E0C
6 changed files with 21 additions and 39 deletions

View file

@ -26,13 +26,3 @@ impl VoipId {
VoipId::from_borrowed(&id.simple().to_string()).to_owned()
}
}
#[cfg(test)]
mod tests {
use super::VoipId;
#[test]
fn try_from() {
<&VoipId>::try_from("this_-_a_valid_secret_1337").unwrap();
}
}

View file

@ -172,12 +172,12 @@ mod tests {
#[test]
fn valid_version_1() {
assert_eq!(VoipVersionId::try_from("1"), Ok(VoipVersionId::V1));
assert_eq!(VoipVersionId::from("1"), VoipVersionId::V1);
}
#[test]
fn valid_custom_string_version() {
assert_matches!(VoipVersionId::try_from("io.ruma.2"), Ok(version));
assert_matches!(VoipVersionId::from("io.ruma.2"), version);
assert_eq!(version.as_ref(), "io.ruma.2");
}
@ -203,13 +203,13 @@ mod tests {
#[test]
fn serialize_custom_string() {
let version = VoipVersionId::try_from("io.ruma.1").unwrap();
let version = VoipVersionId::from("io.ruma.1");
assert_eq!(to_json_value(&version).unwrap(), json!("io.ruma.1"));
}
#[test]
fn deserialize_custom_string() {
let version = VoipVersionId::try_from("io.ruma.1").unwrap();
let version = VoipVersionId::from("io.ruma.1");
assert_eq!(from_json_value::<VoipVersionId>(json!("io.ruma.1")).unwrap(), version);
}
}

View file

@ -47,16 +47,13 @@ fn plain_text_content_serialization() {
#[test]
fn unknown_mimetype_content_serialization() {
let message_event_content = MessageEventContent::from(
TextContentBlock::try_from(vec![
TextRepresentation::plain("> <@test:example.com> test\n\ntest reply"),
TextRepresentation::new(
"application/json",
r#"{ "quote": "<@test:example.com> test", "reply": "test reply" }"#,
),
])
.unwrap(),
);
let message_event_content = MessageEventContent::from(TextContentBlock::from(vec![
TextRepresentation::plain("> <@test:example.com> test\n\ntest reply"),
TextRepresentation::new(
"application/json",
r#"{ "quote": "<@test:example.com> test", "reply": "test reply" }"#,
),
]));
assert_eq!(
to_json_value(&message_event_content).unwrap(),
@ -332,12 +329,11 @@ fn emote_event_deserialization() {
#[test]
#[cfg(feature = "unstable-msc3554")]
fn lang_serialization() {
let content = TextContentBlock::try_from(vec![
let content = TextContentBlock::from(vec![
assign!(TextRepresentation::plain("Bonjour le monde !"), { lang: "fr".into() }),
assign!(TextRepresentation::plain("Hallo Welt!"), { lang: "de".into() }),
assign!(TextRepresentation::plain("Hello World!"), { lang: "en".into() }),
])
.unwrap();
]);
assert_eq!(
to_json_value(content).unwrap(),

View file

@ -76,8 +76,8 @@ use self::{
/// }
/// ```
/// (The enum name has to be a valid identifier for `<EventKind as Parse>::parse`)
//// TODO: Change above (`<EventKind as Parse>::parse`) to [] after fully qualified syntax is
//// supported: https://github.com/rust-lang/rust/issues/74563
///// TODO: Change above (`<EventKind as Parse>::parse`) to [] after fully qualified syntax is
///// supported: https://github.com/rust-lang/rust/issues/74563
#[proc_macro]
pub fn event_enum(input: TokenStream) -> TokenStream {
let event_enum_input = syn::parse_macro_input!(input as EventEnumInput);

View file

@ -986,7 +986,7 @@ mod tests {
let encoded_public_key = Base64::new(newly_generated_key_pair.public_key().to_vec());
let version = ServerSigningKeyId::from_parts(
SigningKeyAlgorithm::Ed25519,
key_pair_sender.version().try_into().unwrap(),
key_pair_sender.version().into(),
);
sender_key_map.insert(version.to_string(), encoded_public_key);
public_key_map.insert("domain-sender".to_owned(), sender_key_map);
@ -1160,10 +1160,8 @@ mod tests {
fn add_key_to_map(public_key_map: &mut PublicKeyMap, name: &str, pair: &Ed25519KeyPair) {
let sender_key_map = public_key_map.entry(name.to_owned()).or_default();
let encoded_public_key = Base64::new(pair.public_key().to_vec());
let version = ServerSigningKeyId::from_parts(
SigningKeyAlgorithm::Ed25519,
pair.version().try_into().unwrap(),
);
let version =
ServerSigningKeyId::from_parts(SigningKeyAlgorithm::Ed25519, pair.version().into());
sender_key_map.insert(version.to_string(), encoded_public_key);
}
@ -1177,7 +1175,7 @@ mod tests {
let encoded_public_key = Base64::new(pair.public_key().to_vec());
let version = ServerSigningKeyId::from_parts(
SigningKeyAlgorithm::from("an-unknown-algorithm"),
pair.version().try_into().unwrap(),
pair.version().into(),
);
sender_key_map.insert(version.to_string(), encoded_public_key);

View file

@ -8,10 +8,8 @@ static PKCS8_ED25519_DER: &[u8] = include_bytes!("./keys/ed25519.der");
fn add_key_to_map(public_key_map: &mut PublicKeyMap, name: &str, pair: &Ed25519KeyPair) {
let sender_key_map = public_key_map.entry(name.to_owned()).or_default();
let encoded_public_key = Base64::new(pair.public_key().to_vec());
let version = ServerSigningKeyId::from_parts(
SigningKeyAlgorithm::Ed25519,
pair.version().try_into().unwrap(),
);
let version =
ServerSigningKeyId::from_parts(SigningKeyAlgorithm::Ed25519, pair.version().into());
sender_key_map.insert(version.to_string(), encoded_public_key);
}