Validate optional status messages and verify talk requests on beta14
This commit is contained in:
1 parent
380e9d4b63
commit
c80219b1a3
6 files changed
+31
-3
No files matched your search
@@ -317,6 +317,28 @@ fn connect_and_disconnect_validate_arguments_before_network_io() {
|
||||
core.shutdown();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn status_messages_are_optional_but_must_be_valid_when_present() {
|
||||
let dir=TempDir::new("status-message-args");
|
||||
let mut core=Core::start(&dir.0);
|
||||
for (cmd, flag, max) in [("set_away", "away", 80), ("talk_request", "request", 50)] {
|
||||
let limit="\u{10000}".repeat(max);
|
||||
for (enabled,msg) in [(true,Value::Null),(true,json!(format!("{limit}x"))),
|
||||
(true,json!("bad\u{85}message")),(false,json!(""))] {
|
||||
let mut args=json!({"message":msg});args[flag]=enabled.into();
|
||||
let (reply,_) = core.request("invalid-status",cmd,args);
|
||||
assert_eq!(reply["error"]["code"],"bad_request","{cmd}: {reply}");
|
||||
}
|
||||
for (enabled,msg) in [(true,Some(limit)),(false,None)] {
|
||||
let mut args=json!({});args[flag]=enabled.into();
|
||||
if let Some(msg)=msg {args["message"]=msg.into();}
|
||||
let (reply,_) = core.request("valid-status",cmd,args);
|
||||
assert_eq!(reply["error"]["code"],"not_connected","{cmd}: {reply}");
|
||||
}
|
||||
}
|
||||
core.shutdown();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn channel_queries_validate_arguments_before_connection_lookup() {
|
||||
let dir = TempDir::new("channel-query-args");
|
||||
|
||||
Reference in new issue
Block a user