mirror of
https://github.com/openai/codex.git
synced 2026-11-05 20:10:33 +00:00
Shrink app.rs below the blob policy threshold, clean up dead-code fallout, and update stale exec-server listen URL test expectations. Co-authored-by: Codex <noreply@openai.com>
51 lines
1.4 KiB
Rust
51 lines
1.4 KiB
Rust
use std::net::SocketAddr;
|
|
|
|
use pretty_assertions::assert_eq;
|
|
|
|
use super::DEFAULT_LISTEN_URL;
|
|
use super::parse_listen_url;
|
|
|
|
#[test]
|
|
fn parse_listen_url_accepts_default_websocket_url() {
|
|
let bind_address =
|
|
parse_listen_url(DEFAULT_LISTEN_URL).expect("default listen URL should parse");
|
|
assert_eq!(
|
|
bind_address,
|
|
"127.0.0.1:0"
|
|
.parse::<SocketAddr>()
|
|
.expect("valid socket address")
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn parse_listen_url_accepts_websocket_url() {
|
|
let bind_address =
|
|
parse_listen_url("ws://127.0.0.1:1234").expect("websocket listen URL should parse");
|
|
assert_eq!(
|
|
bind_address,
|
|
"127.0.0.1:1234"
|
|
.parse::<SocketAddr>()
|
|
.expect("valid socket address")
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn parse_listen_url_rejects_invalid_websocket_url() {
|
|
let err = parse_listen_url("ws://localhost:1234")
|
|
.expect_err("hostname bind address should be rejected");
|
|
assert_eq!(
|
|
err.to_string(),
|
|
"invalid websocket --listen URL `ws://localhost:1234`; expected `ws://IP:PORT`"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn parse_listen_url_rejects_unsupported_url() {
|
|
let err =
|
|
parse_listen_url("http://127.0.0.1:1234").expect_err("unsupported scheme should fail");
|
|
assert_eq!(
|
|
err.to_string(),
|
|
"unsupported --listen URL `http://127.0.0.1:1234`; expected `ws://IP:PORT` or `stdio://`"
|
|
);
|
|
}
|