2023-04-07 23:09:55 +02:00
|
|
|
use nu_test_support::nu;
|
2022-07-12 13:03:50 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn error_label_works() {
|
2023-04-07 23:09:55 +02:00
|
|
|
let actual = nu!("error make {msg:foo label:{text:unseen}}");
|
2022-07-12 13:03:50 +02:00
|
|
|
|
|
|
|
assert!(actual.err.contains("unseen"));
|
|
|
|
assert!(actual.err.contains("╰──"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn no_span_if_unspanned() {
|
2023-04-07 23:09:55 +02:00
|
|
|
let actual = nu!("error make -u {msg:foo label:{text:unseen}}");
|
2022-07-12 13:03:50 +02:00
|
|
|
|
|
|
|
assert!(!actual.err.contains("unseen"));
|
|
|
|
}
|
2023-03-23 20:31:06 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn error_start_bigger_than_end_should_fail() {
|
2023-04-07 23:09:55 +02:00
|
|
|
let actual = nu!("error make {msg: foo label: {text: bar start 456 end 123}}");
|
2023-03-23 20:31:06 +01:00
|
|
|
|
|
|
|
assert!(!actual.err.contains("invalid error format"));
|
|
|
|
assert!(!actual
|
|
|
|
.err
|
|
|
|
.contains("`$.label.start` should be smaller than `$.label.end`"));
|
|
|
|
}
|