Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve error tests #407

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 2 additions & 13 deletions crates/cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,7 @@ mod test {
inner: &error,
};
let display = format!("{error_fmt}");
assert_eq!(display.lines().count(), 6);
assert!(display.contains("Cannot read configuration."));
assert!(
display.contains("Caused by"),
"Should display the error chain"
);
assert!(display.contains("test error"));
assert_eq!(display, "\u{1b}[31mError:\u{1b}[0m \u{1b}[1mCannot read configuration.\u{1b}[0m\n\u{1b}[34mHelp:\u{1b}[0m Please add an sgconfig.yml configuration file in the project root to run the scan command.\n\u{1b}[1;2mSee also:\u{1b}[0m \u{1b}]8;;https://ast-grep.github.io/guide/rule-config.html\u{1b}\\\u{1b}[3;36mhttps://ast-grep.github.io/guide/rule-config.html\u{1b}[0m\u{1b}]8;;\u{1b}\\\n\n\u{1b}[31m×\u{1b}[0m Caused by\n\u{1b}[31m╰▻\u{1b}[0m test error\n");
}

#[test]
Expand All @@ -279,11 +273,6 @@ mod test {
inner: &error,
};
let display = format!("{error_fmt}");
assert_eq!(display.lines().count(), 3);
assert!(display.contains("Cannot read configuration."));
assert!(
!display.contains("Caused by"),
"Should not contain error chain"
);
assert_eq!(display, "\u{1b}[31mError:\u{1b}[0m \u{1b}[1mCannot read configuration.\u{1b}[0m\n\u{1b}[34mHelp:\u{1b}[0m Please add an sgconfig.yml configuration file in the project root to run the scan command.\n\u{1b}[1;2mSee also:\u{1b}[0m \u{1b}]8;;https://ast-grep.github.io/guide/rule-config.html\u{1b}\\\u{1b}[3;36mhttps://ast-grep.github.io/guide/rule-config.html\u{1b}[0m\u{1b}]8;;\u{1b}\\\n");
}
}