Seal the fetch target: one value holds the URL and its host
Implemented-By: OpenCode session (model recorded in docs/implementer-log.md)
This commit is contained in:
@@ -289,16 +289,16 @@ fn each_tool_parses_its_own_arguments() {
|
||||
cwd: Some("/home/kyle".to_string())
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
parse(
|
||||
ToolName::HttpFetch,
|
||||
r#"{"url":"https://www.example.com/a"}"#
|
||||
),
|
||||
Ok(ToolArgs::HttpFetch {
|
||||
url: "https://www.example.com/a".to_string(),
|
||||
host: "www.example.com".to_string()
|
||||
})
|
||||
// A `FetchUrl` cannot be built outside `args`, so the parsed value is read through its getters.
|
||||
let fetched = parse(
|
||||
ToolName::HttpFetch,
|
||||
r#"{"url":"https://www.example.com/a"}"#,
|
||||
);
|
||||
let Ok(ToolArgs::HttpFetch(target)) = fetched else {
|
||||
panic!("{fetched:?}")
|
||||
};
|
||||
assert_eq!(target.url(), "https://www.example.com/a");
|
||||
assert_eq!(target.host(), "www.example.com");
|
||||
// Field order and white space in the request do not matter.
|
||||
assert_eq!(
|
||||
parse(
|
||||
|
||||
Reference in New Issue
Block a user