Rename variable in parse_command
test
Rename `map` to `headers` inside the `parse_command` test to improve readability.
This commit is contained in:
parent
5a88fb892b
commit
87d6f58f72
1 changed files with 23 additions and 13 deletions
36
src/main.rs
36
src/main.rs
|
@ -609,48 +609,53 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_command() {
|
fn parse_command() {
|
||||||
let mut map = HeaderMap::new();
|
let mut headers = HeaderMap::new();
|
||||||
map.add_raw("X-Gitea-Event", "something");
|
headers.add_raw("X-Gitea-Event", "something");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
replace_parameters("command", &map, &serde_json::Value::Null).unwrap(),
|
replace_parameters("command", &headers, &serde_json::Value::Null).unwrap(),
|
||||||
"command"
|
"command"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
replace_parameters(" command", &map, &serde_json::Value::Null).unwrap(),
|
replace_parameters(" command", &headers, &serde_json::Value::Null).unwrap(),
|
||||||
" command"
|
" command"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
replace_parameters("command ", &map, &serde_json::Value::Null).unwrap(),
|
replace_parameters("command ", &headers, &serde_json::Value::Null).unwrap(),
|
||||||
"command "
|
"command "
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
replace_parameters(" command ", &map, &serde_json::Value::Null).unwrap(),
|
replace_parameters(" command ", &headers, &serde_json::Value::Null).unwrap(),
|
||||||
" command "
|
" command "
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
replace_parameters("command command ", &map, &serde_json::Value::Null).unwrap(),
|
replace_parameters("command command ", &headers, &serde_json::Value::Null).unwrap(),
|
||||||
"command command "
|
"command command "
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
replace_parameters("{{ /foo }} command", &map, &json!({ "foo": "bar" })).unwrap(),
|
replace_parameters("{{ /foo }} command", &headers, &json!({ "foo": "bar" })).unwrap(),
|
||||||
"bar command"
|
"bar command"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
replace_parameters(" command {{ /foo }} ", &map, &json!({ "foo": "bar" })).unwrap(),
|
replace_parameters(
|
||||||
|
" command {{ /foo }} ",
|
||||||
|
&headers,
|
||||||
|
&json!({ "foo": "bar" })
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
" command bar "
|
" command bar "
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
replace_parameters(
|
replace_parameters(
|
||||||
"{{ /foo }} command{{/field1/foo}}",
|
"{{ /foo }} command{{/field1/foo}}",
|
||||||
&map,
|
&headers,
|
||||||
&json!({ "foo": "bar", "field1": { "foo": "baz" } })
|
&json!({ "foo": "bar", "field1": { "foo": "baz" } })
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
@ -658,14 +663,19 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
replace_parameters(" command {{ /foo }} ", &map, &json!({ "foo": "bar" })).unwrap(),
|
replace_parameters(
|
||||||
|
" command {{ /foo }} ",
|
||||||
|
&headers,
|
||||||
|
&json!({ "foo": "bar" })
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
" command bar "
|
" command bar "
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
replace_parameters(
|
replace_parameters(
|
||||||
" {{ /field1/foo }} command",
|
" {{ /field1/foo }} command",
|
||||||
&map,
|
&headers,
|
||||||
&json!({ "field1": { "foo": "bar" } })
|
&json!({ "field1": { "foo": "bar" } })
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
@ -675,7 +685,7 @@ mod tests {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
replace_parameters(
|
replace_parameters(
|
||||||
" {{ header X-Gitea-Event }} command",
|
" {{ header X-Gitea-Event }} command",
|
||||||
&map,
|
&headers,
|
||||||
&json!({ "field1": { "foo": "bar" } })
|
&json!({ "field1": { "foo": "bar" } })
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
|
Loading…
Reference in a new issue