Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions modeling-cmds/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ pub enum OkWebSocketResponseData {
/// Result after executing KCL.
result: Result<crate::exec_kcl::ExecKclProjectOk, crate::exec_kcl::ExecKclProjectErr>,
},

/// Request that the client end this connection and establish a new session
/// using normal authentication and authorization.
/// This does not guarantee that a new session will be accepted.
Reconnect {},
}

/// Successful Websocket response.
Expand Down Expand Up @@ -912,6 +917,22 @@ mod tests {

const REQ_ID: Uuid = uuid::uuid!("cc30d5e2-482b-4498-b5d2-6131c30a50a4");

#[test]
fn reconnect_response_round_trip() {
let response = WebSocketResponse::success(None, OkWebSocketResponseData::Reconnect {});
let expected = serde_json::json!({
"success": true,
"request_id": null,
"resp": {
"type": "reconnect",
"data": {}
}
});
assert_eq!(serde_json::to_value(&response).unwrap(), expected);
let decoded: WebSocketResponse = serde_json::from_value(expected).unwrap();
assert_eq!(decoded, response);
}

#[test]
fn serialize_websocket_modeling_ok() {
let actual = WebSocketResponse::Success(SuccessWebSocketResponse {
Expand Down