implement titan test

This commit is contained in:
yggverse 2025-01-14 00:42:59 +02:00
parent df191c8e25
commit ac53f73a60

View file

@ -9,10 +9,36 @@ fn client_connection_request_gemini() {
assert_eq!( assert_eq!(
&match Request::gemini(Uri::parse(REQUEST, UriFlags::NONE).unwrap()) { &match Request::gemini(Uri::parse(REQUEST, UriFlags::NONE).unwrap()) {
Request::Gemini(request) => request.uri.to_string(), Request::Gemini(request) => request.uri.to_string(),
Request::Titan(_) => panic!(), _ => panic!(),
}, },
REQUEST REQUEST
); );
} }
#[test]
fn client_connection_request_titan() {
const DATA: &[u8] = &[1, 2, 3];
const MIME: &str = "plain/text";
const TOKEN: &str = "token";
const ARGUMENT: &str = "argument";
const REQUEST: &str = "titan://geminiprotocol.net/raw/Test";
assert_eq!(
std::str::from_utf8(
&Request::titan(
Uri::parse(&format!("{REQUEST}?arg={ARGUMENT}"), UriFlags::NONE).unwrap(),
DATA.to_vec(),
Some(MIME.to_string()),
Some(TOKEN.to_string()),
)
.to_bytes()
)
.unwrap(),
format!(
"{REQUEST};size={};mime={MIME};token={TOKEN}?arg={ARGUMENT}\r\n{}",
DATA.len(),
std::str::from_utf8(DATA).unwrap(),
)
);
}
// @TODO // @TODO