mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-10 06:54:12 +00:00
Add test case to find errors that are only used for federation
This commit is contained in:
parent
bd2c97542f
commit
c422b88cf8
2 changed files with 20 additions and 5 deletions
|
@ -23,6 +23,7 @@ pub enum LemmyErrorType {
|
|||
CouldntUpdateComment,
|
||||
CouldntUpdatePrivateMessage,
|
||||
CannotLeaveAdmin,
|
||||
// TODO: also remove the translations of unused errors
|
||||
PictrsResponseError(String),
|
||||
PictrsPurgeResponseError(String),
|
||||
ImageUrlMissingPathSegments,
|
||||
|
|
|
@ -9,20 +9,34 @@ fn test_errors_used() {
|
|||
current_dir.pop();
|
||||
current_dir.pop();
|
||||
for error in LemmyErrorType::iter() {
|
||||
let mut command = Command::new("grep");
|
||||
let command = command
|
||||
let mut grep_all = Command::new("grep");
|
||||
let grep_all = grep_all
|
||||
.current_dir(current_dir.clone())
|
||||
.arg("-R")
|
||||
.arg("--exclude=error.rs")
|
||||
.arg(error.to_string())
|
||||
.arg("crates/")
|
||||
.arg("src/");
|
||||
let output = command.output().unwrap();
|
||||
let stdout = std::str::from_utf8(&output.stdout).unwrap();
|
||||
if stdout.len() == 0 {
|
||||
let output = grep_all.output().unwrap();
|
||||
let grep_all_out = std::str::from_utf8(&output.stdout).unwrap();
|
||||
|
||||
let mut grep_apub = Command::new("grep");
|
||||
let grep_apub = grep_apub
|
||||
.current_dir(current_dir.clone())
|
||||
.arg("-R")
|
||||
.arg(error.to_string())
|
||||
.arg("crates/apub/");
|
||||
let output = grep_apub.output().unwrap();
|
||||
let grep_apub_out = std::str::from_utf8(&output.stdout).unwrap();
|
||||
|
||||
if grep_all_out.len() == 0 {
|
||||
println!("LemmyErrorType::{} is unused", error);
|
||||
unused_error_found = true;
|
||||
}
|
||||
if grep_all_out == grep_apub_out {
|
||||
println!("LemmyErrorType::{} is only used for federation", error);
|
||||
unused_error_found = true;
|
||||
}
|
||||
}
|
||||
assert!(unused_error_found == false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue