mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-25 12:05:32 +03:00
Use operator for equals predicate in tests.
This commit is contained in:
parent
965246f063
commit
c2342b90cb
@ -721,7 +721,7 @@ HTTP/1.0 200
|
||||
let content = r#"GET http://example.com
|
||||
HTTP/1.0 200
|
||||
[Asserts]
|
||||
xpath "strong(//head/title)" equals "Hello"
|
||||
xpath "strong(//head/title)" == "Hello"
|
||||
"#;
|
||||
let filename = "test.hurl";
|
||||
let error = runner::Error {
|
||||
@ -734,7 +734,7 @@ xpath "strong(//head/title)" equals "Hello"
|
||||
r#"Invalid XPath expression
|
||||
--> test.hurl:4:7
|
||||
|
|
||||
4 | xpath "strong(//head/title)" equals "Hello"
|
||||
4 | xpath "strong(//head/title)" == "Hello"
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ the XPath expression is not valid
|
||||
|"#
|
||||
)
|
||||
|
@ -407,7 +407,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_predicate() {
|
||||
let mut reader = Reader::new("not equals true");
|
||||
let mut reader = Reader::new("not == true");
|
||||
assert_eq!(
|
||||
predicate(&mut reader).unwrap(),
|
||||
Predicate {
|
||||
@ -417,14 +417,14 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 4, 1, 5),
|
||||
},
|
||||
predicate_func: PredicateFunc {
|
||||
source_info: SourceInfo::new(1, 5, 1, 16),
|
||||
source_info: SourceInfo::new(1, 5, 1, 12),
|
||||
value: PredicateFuncValue::Equal {
|
||||
space0: Whitespace {
|
||||
value: String::from(" "),
|
||||
source_info: SourceInfo::new(1, 11, 1, 12),
|
||||
source_info: SourceInfo::new(1, 7, 1, 8),
|
||||
},
|
||||
value: PredicateValue::Bool(true),
|
||||
operator: false,
|
||||
operator: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -433,7 +433,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_predicate_func() {
|
||||
let mut reader = Reader::new("tata equals 1");
|
||||
let mut reader = Reader::new("tata == 1");
|
||||
let error = predicate_func(&mut reader).err().unwrap();
|
||||
assert_eq!(error.pos, Pos { line: 1, column: 1 });
|
||||
assert!(!error.recoverable);
|
||||
@ -442,21 +442,21 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_equal_predicate() {
|
||||
let mut reader = Reader::new("equals true");
|
||||
let mut reader = Reader::new("== true");
|
||||
assert_eq!(
|
||||
equal_predicate(&mut reader).unwrap(),
|
||||
PredicateFuncValue::Equal {
|
||||
value: PredicateValue::Bool(true),
|
||||
space0: Whitespace {
|
||||
value: String::from(" "),
|
||||
source_info: SourceInfo::new(1, 7, 1, 9),
|
||||
source_info: SourceInfo::new(1, 3, 1, 5),
|
||||
},
|
||||
|
||||
operator: false,
|
||||
operator: true,
|
||||
}
|
||||
);
|
||||
|
||||
let mut reader = Reader::new("equals 1.1");
|
||||
let mut reader = Reader::new("== 1.1");
|
||||
assert_eq!(
|
||||
equal_predicate(&mut reader).unwrap(),
|
||||
PredicateFuncValue::Equal {
|
||||
@ -466,25 +466,12 @@ mod tests {
|
||||
}),
|
||||
space0: Whitespace {
|
||||
value: String::from(" "),
|
||||
source_info: SourceInfo::new(1, 7, 1, 8),
|
||||
source_info: SourceInfo::new(1, 3, 1, 4),
|
||||
},
|
||||
operator: false,
|
||||
operator: true,
|
||||
}
|
||||
);
|
||||
|
||||
let mut reader = Reader::new("equals 2");
|
||||
assert_eq!(
|
||||
equal_predicate(&mut reader).unwrap(),
|
||||
PredicateFuncValue::Equal {
|
||||
value: PredicateValue::Integer(2),
|
||||
space0: Whitespace {
|
||||
value: String::from(" "),
|
||||
source_info: SourceInfo::new(1, 7, 1, 8),
|
||||
},
|
||||
operator: false,
|
||||
},
|
||||
);
|
||||
|
||||
let mut reader = Reader::new("== 2");
|
||||
assert_eq!(
|
||||
equal_predicate(&mut reader).unwrap(),
|
||||
@ -498,7 +485,7 @@ mod tests {
|
||||
},
|
||||
);
|
||||
|
||||
let mut reader = Reader::new("equals \"Bob\"");
|
||||
let mut reader = Reader::new("== \"Bob\"");
|
||||
assert_eq!(
|
||||
equal_predicate(&mut reader).unwrap(),
|
||||
PredicateFuncValue::Equal {
|
||||
@ -508,42 +495,42 @@ mod tests {
|
||||
value: "Bob".to_string(),
|
||||
encoded: "Bob".to_string(),
|
||||
}],
|
||||
source_info: SourceInfo::new(1, 8, 1, 13),
|
||||
source_info: SourceInfo::new(1, 4, 1, 9),
|
||||
}),
|
||||
space0: Whitespace {
|
||||
value: String::from(" "),
|
||||
source_info: SourceInfo::new(1, 7, 1, 8),
|
||||
source_info: SourceInfo::new(1, 3, 1, 4),
|
||||
},
|
||||
operator: false,
|
||||
operator: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_equal_expression_predicate() {
|
||||
let mut reader = Reader::new("equals {{count}}");
|
||||
let mut reader = Reader::new("== {{count}}");
|
||||
assert_eq!(
|
||||
equal_predicate(&mut reader).unwrap(),
|
||||
PredicateFuncValue::Equal {
|
||||
value: PredicateValue::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 10, 1, 10),
|
||||
source_info: SourceInfo::new(1, 6, 1, 6),
|
||||
},
|
||||
variable: Variable {
|
||||
name: "count".to_string(),
|
||||
source_info: SourceInfo::new(1, 10, 1, 15),
|
||||
source_info: SourceInfo::new(1, 6, 1, 11),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 15, 1, 15),
|
||||
source_info: SourceInfo::new(1, 11, 1, 11),
|
||||
},
|
||||
}),
|
||||
space0: Whitespace {
|
||||
value: String::from(" "),
|
||||
source_info: SourceInfo::new(1, 7, 1, 8),
|
||||
source_info: SourceInfo::new(1, 3, 1, 4),
|
||||
},
|
||||
operator: false,
|
||||
operator: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -676,8 +676,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_asserts_section() {
|
||||
let mut reader =
|
||||
Reader::new("[Asserts]\nheader \"Location\" equals \"https://google.fr\"\n");
|
||||
let mut reader = Reader::new("[Asserts]\nheader \"Location\" == \"https://google.fr\"\n");
|
||||
|
||||
assert_eq!(
|
||||
response_section(&mut reader).unwrap(),
|
||||
@ -733,11 +732,11 @@ mod tests {
|
||||
source_info: SourceInfo::new(2, 19, 2, 19),
|
||||
},
|
||||
predicate_func: PredicateFunc {
|
||||
source_info: SourceInfo::new(2, 19, 2, 45),
|
||||
source_info: SourceInfo::new(2, 19, 2, 41),
|
||||
value: PredicateFuncValue::Equal {
|
||||
space0: Whitespace {
|
||||
value: String::from(" "),
|
||||
source_info: SourceInfo::new(2, 25, 2, 26),
|
||||
source_info: SourceInfo::new(2, 21, 2, 22),
|
||||
},
|
||||
value: PredicateValue::String(Template {
|
||||
delimiter: Some('"'),
|
||||
@ -745,21 +744,21 @@ mod tests {
|
||||
value: "https://google.fr".to_string(),
|
||||
encoded: "https://google.fr".to_string(),
|
||||
}],
|
||||
source_info: SourceInfo::new(2, 26, 2, 45),
|
||||
source_info: SourceInfo::new(2, 22, 2, 41),
|
||||
}),
|
||||
operator: false,
|
||||
operator: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
line_terminator0: LineTerminator {
|
||||
space0: Whitespace {
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(2, 45, 2, 45),
|
||||
source_info: SourceInfo::new(2, 41, 2, 41),
|
||||
},
|
||||
comment: None,
|
||||
newline: Whitespace {
|
||||
value: String::from("\n"),
|
||||
source_info: SourceInfo::new(2, 45, 3, 1),
|
||||
source_info: SourceInfo::new(2, 41, 3, 1),
|
||||
},
|
||||
},
|
||||
}]),
|
||||
@ -770,7 +769,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_asserts_section_error() {
|
||||
let mut reader = Reader::new("x[Assertsx]\nheader Location equals \"https://google.fr\"\n");
|
||||
let mut reader = Reader::new("x[Assertsx]\nheader Location == \"https://google.fr\"\n");
|
||||
let error = response_section(&mut reader).err().unwrap();
|
||||
assert_eq!(error.pos, Pos { line: 1, column: 1 });
|
||||
assert_eq!(
|
||||
@ -781,7 +780,7 @@ mod tests {
|
||||
);
|
||||
assert!(error.recoverable);
|
||||
|
||||
let mut reader = Reader::new("[Assertsx]\nheader Location equals \"https://google.fr\"\n");
|
||||
let mut reader = Reader::new("[Assertsx]\nheader Location == \"https://google.fr\"\n");
|
||||
let error = response_section(&mut reader).err().unwrap();
|
||||
assert_eq!(error.pos, Pos { line: 1, column: 2 });
|
||||
assert_eq!(
|
||||
@ -1238,7 +1237,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_assert() {
|
||||
let mut reader = Reader::new("header \"Location\" equals \"https://google.fr\"");
|
||||
let mut reader = Reader::new("header \"Location\" == \"https://google.fr\"");
|
||||
let assert0 = assert(&mut reader).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
@ -1265,7 +1264,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_assert_jsonpath() {
|
||||
let mut reader = Reader::new("jsonpath \"$.errors\" equals 5");
|
||||
let mut reader = Reader::new("jsonpath \"$.errors\" == 5");
|
||||
|
||||
assert_eq!(
|
||||
assert(&mut reader).unwrap().predicate,
|
||||
@ -1276,14 +1275,14 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 21, 1, 21),
|
||||
},
|
||||
predicate_func: PredicateFunc {
|
||||
source_info: SourceInfo::new(1, 21, 1, 29),
|
||||
source_info: SourceInfo::new(1, 21, 1, 25),
|
||||
value: PredicateFuncValue::Equal {
|
||||
space0: Whitespace {
|
||||
value: String::from(" "),
|
||||
source_info: SourceInfo::new(1, 27, 1, 28),
|
||||
source_info: SourceInfo::new(1, 23, 1, 24),
|
||||
},
|
||||
value: PredicateValue::Integer(5),
|
||||
operator: false,
|
||||
operator: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user