mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-06 16:06:08 +00:00
Add Chinese responsibility summaries to every backend Rust source, test, and build script. Remove sentence-ending periods from comments while preserving meaningful dots in URLs, versions, identifiers, and examples. Keep generated SDK documentation in sync with its contract generator, group middleware module declarations and exports, and record the comment conventions in the development skill. Validated with Rustfmt, strict Clippy, backend tests, documentation tests, and skill validation. Database-backed integration cases were skipped because dedicated PostgreSQL and Redis test services were not configured. Co-authored-by: Codex <noreply@openai.com>
52 lines
1.7 KiB
Rust
52 lines
1.7 KiB
Rust
//! 验证网关基础命令无需加载配置,并拒绝非法或多余参数
|
|
|
|
use std::{fs, process::Command};
|
|
|
|
#[test]
|
|
fn basic_cli_options_do_not_load_configuration_and_reject_unexpected_arguments() {
|
|
let directory = tempfile::tempdir().unwrap();
|
|
fs::create_dir(directory.path().join("deploy")).unwrap();
|
|
fs::write(directory.path().join("deploy/config.yaml"), "invalid: [").unwrap();
|
|
for flag in ["--help", "-h", "help", "--version", "-V"] {
|
|
let output = Command::new(env!("CARGO_BIN_EXE_codex-proxy-rs"))
|
|
.arg(flag)
|
|
.current_dir(directory.path())
|
|
.env_clear()
|
|
.output()
|
|
.unwrap();
|
|
assert!(output.status.success(), "{flag}");
|
|
assert!(!output.stdout.is_empty());
|
|
assert!(output.stderr.is_empty());
|
|
}
|
|
for args in [
|
|
vec!["unknown"],
|
|
vec!["--help", "extra"],
|
|
vec!["serve", "extra"],
|
|
] {
|
|
let output = Command::new(env!("CARGO_BIN_EXE_codex-proxy-rs"))
|
|
.args(args)
|
|
.current_dir(directory.path())
|
|
.env_clear()
|
|
.output()
|
|
.unwrap();
|
|
assert!(!output.status.success());
|
|
assert!(output.stdout.is_empty());
|
|
assert!(!String::from_utf8_lossy(&output.stderr).contains("configuration"));
|
|
}
|
|
}
|
|
|
|
#[cfg(unix)]
|
|
#[test]
|
|
fn non_utf8_command_is_not_interpreted_as_serve() {
|
|
use std::os::unix::ffi::OsStringExt as _;
|
|
|
|
let output = Command::new(env!("CARGO_BIN_EXE_codex-proxy-rs"))
|
|
.arg(std::ffi::OsString::from_vec(vec![0xff]))
|
|
.env_clear()
|
|
.output()
|
|
.unwrap();
|
|
assert!(!output.status.success());
|
|
assert!(output.stdout.is_empty());
|
|
assert!(String::from_utf8_lossy(&output.stderr).contains("command must be UTF-8"));
|
|
}
|