chore: cfg(test) a test in rpc. (#3978)
The test in particular should be included in our release binary at present. :/ Release Notes: - N/A
This commit is contained in:
parent
824d06e2b2
commit
ab6cd1d93a
2 changed files with 47 additions and 31 deletions
23
Cargo.lock
generated
23
Cargo.lock
generated
|
@ -1515,7 +1515,7 @@ dependencies = [
|
||||||
"tonic",
|
"tonic",
|
||||||
"tower",
|
"tower",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-log",
|
"tracing-log 0.1.3",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"unindent",
|
"unindent",
|
||||||
"util",
|
"util",
|
||||||
|
@ -6930,9 +6930,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sharded-slab"
|
name = "sharded-slab"
|
||||||
version = "0.1.4"
|
version = "0.1.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
|
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
@ -8316,6 +8316,17 @@ dependencies = [
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-log"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
"tracing-core",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-serde"
|
name = "tracing-serde"
|
||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
|
@ -8328,9 +8339,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-subscriber"
|
name = "tracing-subscriber"
|
||||||
version = "0.3.17"
|
version = "0.3.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77"
|
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"matchers",
|
"matchers",
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
|
@ -8343,7 +8354,7 @@ dependencies = [
|
||||||
"thread_local",
|
"thread_local",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
"tracing-log",
|
"tracing-log 0.2.0",
|
||||||
"tracing-serde",
|
"tracing-serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -76,30 +76,35 @@ impl Notification {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[cfg(test)]
|
||||||
fn test_notification() {
|
mod tests {
|
||||||
// Notifications can be serialized and deserialized.
|
use crate::Notification;
|
||||||
for notification in [
|
|
||||||
Notification::ContactRequest { sender_id: 1 },
|
|
||||||
Notification::ContactRequestAccepted { responder_id: 2 },
|
|
||||||
Notification::ChannelInvitation {
|
|
||||||
channel_id: 100,
|
|
||||||
channel_name: "the-channel".into(),
|
|
||||||
inviter_id: 50,
|
|
||||||
},
|
|
||||||
Notification::ChannelMessageMention {
|
|
||||||
sender_id: 200,
|
|
||||||
channel_id: 30,
|
|
||||||
message_id: 1,
|
|
||||||
},
|
|
||||||
] {
|
|
||||||
let message = notification.to_proto();
|
|
||||||
let deserialized = Notification::from_proto(&message).unwrap();
|
|
||||||
assert_eq!(deserialized, notification);
|
|
||||||
}
|
|
||||||
|
|
||||||
// When notifications are serialized, the `kind` and `actor_id` fields are
|
#[test]
|
||||||
// stored separately, and do not appear redundantly in the JSON.
|
fn test_notification() {
|
||||||
let notification = Notification::ContactRequest { sender_id: 1 };
|
// Notifications can be serialized and deserialized.
|
||||||
assert_eq!(notification.to_proto().content, "{}");
|
for notification in [
|
||||||
|
Notification::ContactRequest { sender_id: 1 },
|
||||||
|
Notification::ContactRequestAccepted { responder_id: 2 },
|
||||||
|
Notification::ChannelInvitation {
|
||||||
|
channel_id: 100,
|
||||||
|
channel_name: "the-channel".into(),
|
||||||
|
inviter_id: 50,
|
||||||
|
},
|
||||||
|
Notification::ChannelMessageMention {
|
||||||
|
sender_id: 200,
|
||||||
|
channel_id: 30,
|
||||||
|
message_id: 1,
|
||||||
|
},
|
||||||
|
] {
|
||||||
|
let message = notification.to_proto();
|
||||||
|
let deserialized = Notification::from_proto(&message).unwrap();
|
||||||
|
assert_eq!(deserialized, notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
// When notifications are serialized, the `kind` and `actor_id` fields are
|
||||||
|
// stored separately, and do not appear redundantly in the JSON.
|
||||||
|
let notification = Notification::ContactRequest { sender_id: 1 };
|
||||||
|
assert_eq!(notification.to_proto().content, "{}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue