Fix new lints
This commit is contained in:
parent
db06702a0f
commit
c82f600d6a
@ -26,13 +26,3 @@ impl VoipId {
|
|||||||
VoipId::from_borrowed(&id.simple().to_string()).to_owned()
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -172,12 +172,12 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn valid_version_1() {
|
fn valid_version_1() {
|
||||||
assert_eq!(VoipVersionId::try_from("1"), Ok(VoipVersionId::V1));
|
assert_eq!(VoipVersionId::from("1"), VoipVersionId::V1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn valid_custom_string_version() {
|
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");
|
assert_eq!(version.as_ref(), "io.ruma.2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,13 +203,13 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialize_custom_string() {
|
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"));
|
assert_eq!(to_json_value(&version).unwrap(), json!("io.ruma.1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize_custom_string() {
|
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);
|
assert_eq!(from_json_value::<VoipVersionId>(json!("io.ruma.1")).unwrap(), version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,16 +47,13 @@ fn plain_text_content_serialization() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn unknown_mimetype_content_serialization() {
|
fn unknown_mimetype_content_serialization() {
|
||||||
let message_event_content = MessageEventContent::from(
|
let message_event_content = MessageEventContent::from(TextContentBlock::from(vec![
|
||||||
TextContentBlock::try_from(vec![
|
TextRepresentation::plain("> <@test:example.com> test\n\ntest reply"),
|
||||||
TextRepresentation::plain("> <@test:example.com> test\n\ntest reply"),
|
TextRepresentation::new(
|
||||||
TextRepresentation::new(
|
"application/json",
|
||||||
"application/json",
|
r#"{ "quote": "<@test:example.com> test", "reply": "test reply" }"#,
|
||||||
r#"{ "quote": "<@test:example.com> test", "reply": "test reply" }"#,
|
),
|
||||||
),
|
]));
|
||||||
])
|
|
||||||
.unwrap(),
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_json_value(&message_event_content).unwrap(),
|
to_json_value(&message_event_content).unwrap(),
|
||||||
@ -332,12 +329,11 @@ fn emote_event_deserialization() {
|
|||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "unstable-msc3554")]
|
#[cfg(feature = "unstable-msc3554")]
|
||||||
fn lang_serialization() {
|
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("Bonjour le monde !"), { lang: "fr".into() }),
|
||||||
assign!(TextRepresentation::plain("Hallo Welt!"), { lang: "de".into() }),
|
assign!(TextRepresentation::plain("Hallo Welt!"), { lang: "de".into() }),
|
||||||
assign!(TextRepresentation::plain("Hello World!"), { lang: "en".into() }),
|
assign!(TextRepresentation::plain("Hello World!"), { lang: "en".into() }),
|
||||||
])
|
]);
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_json_value(content).unwrap(),
|
to_json_value(content).unwrap(),
|
||||||
|
@ -76,8 +76,8 @@ use self::{
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
/// (The enum name has to be a valid identifier for `<EventKind as Parse>::parse`)
|
/// (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
|
///// TODO: Change above (`<EventKind as Parse>::parse`) to [] after fully qualified syntax is
|
||||||
//// supported: https://github.com/rust-lang/rust/issues/74563
|
///// supported: https://github.com/rust-lang/rust/issues/74563
|
||||||
#[proc_macro]
|
#[proc_macro]
|
||||||
pub fn event_enum(input: TokenStream) -> TokenStream {
|
pub fn event_enum(input: TokenStream) -> TokenStream {
|
||||||
let event_enum_input = syn::parse_macro_input!(input as EventEnumInput);
|
let event_enum_input = syn::parse_macro_input!(input as EventEnumInput);
|
||||||
|
@ -986,7 +986,7 @@ mod tests {
|
|||||||
let encoded_public_key = Base64::new(newly_generated_key_pair.public_key().to_vec());
|
let encoded_public_key = Base64::new(newly_generated_key_pair.public_key().to_vec());
|
||||||
let version = ServerSigningKeyId::from_parts(
|
let version = ServerSigningKeyId::from_parts(
|
||||||
SigningKeyAlgorithm::Ed25519,
|
SigningKeyAlgorithm::Ed25519,
|
||||||
key_pair_sender.version().try_into().unwrap(),
|
key_pair_sender.version().into(),
|
||||||
);
|
);
|
||||||
sender_key_map.insert(version.to_string(), encoded_public_key);
|
sender_key_map.insert(version.to_string(), encoded_public_key);
|
||||||
public_key_map.insert("domain-sender".to_owned(), sender_key_map);
|
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) {
|
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 sender_key_map = public_key_map.entry(name.to_owned()).or_default();
|
||||||
let encoded_public_key = Base64::new(pair.public_key().to_vec());
|
let encoded_public_key = Base64::new(pair.public_key().to_vec());
|
||||||
let version = ServerSigningKeyId::from_parts(
|
let version =
|
||||||
SigningKeyAlgorithm::Ed25519,
|
ServerSigningKeyId::from_parts(SigningKeyAlgorithm::Ed25519, pair.version().into());
|
||||||
pair.version().try_into().unwrap(),
|
|
||||||
);
|
|
||||||
|
|
||||||
sender_key_map.insert(version.to_string(), encoded_public_key);
|
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 encoded_public_key = Base64::new(pair.public_key().to_vec());
|
||||||
let version = ServerSigningKeyId::from_parts(
|
let version = ServerSigningKeyId::from_parts(
|
||||||
SigningKeyAlgorithm::from("an-unknown-algorithm"),
|
SigningKeyAlgorithm::from("an-unknown-algorithm"),
|
||||||
pair.version().try_into().unwrap(),
|
pair.version().into(),
|
||||||
);
|
);
|
||||||
|
|
||||||
sender_key_map.insert(version.to_string(), encoded_public_key);
|
sender_key_map.insert(version.to_string(), encoded_public_key);
|
||||||
|
@ -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) {
|
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 sender_key_map = public_key_map.entry(name.to_owned()).or_default();
|
||||||
let encoded_public_key = Base64::new(pair.public_key().to_vec());
|
let encoded_public_key = Base64::new(pair.public_key().to_vec());
|
||||||
let version = ServerSigningKeyId::from_parts(
|
let version =
|
||||||
SigningKeyAlgorithm::Ed25519,
|
ServerSigningKeyId::from_parts(SigningKeyAlgorithm::Ed25519, pair.version().into());
|
||||||
pair.version().try_into().unwrap(),
|
|
||||||
);
|
|
||||||
|
|
||||||
sender_key_map.insert(version.to_string(), encoded_public_key);
|
sender_key_map.insert(version.to_string(), encoded_public_key);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user