use crate::types::report::phrase::OUTSIDE_PROJECT;
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
pub enum InvalidGitUrl {
#[error("empty")]
Empty,
#[error("URL must not start with \"-\"")]
LeadingDash,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
#[error("empty")]
pub struct InvalidGitTag;
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
pub enum InvalidCommitId {
#[error("empty")]
Empty,
#[error("not a commit id")]
NotACommitId,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
pub enum InvalidSubPath {
#[error("empty")]
Empty,
#[error("must stay inside the repository")]
OutsideRepository,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
pub enum InvalidLocalPath {
#[error("empty")]
Empty,
#[error("absolute paths are not portable")]
AbsolutePath,
#[error("{}", OUTSIDE_PROJECT)]
OutsideProject,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn invalid_git_url_displays_each_message() {
assert_eq!(InvalidGitUrl::Empty.to_string(), "empty");
assert_eq!(
InvalidGitUrl::LeadingDash.to_string(),
"URL must not start with \"-\""
);
}
#[test]
fn invalid_git_tag_displays_empty() {
assert_eq!(InvalidGitTag.to_string(), "empty");
}
#[test]
fn invalid_commit_id_displays_each_message() {
assert_eq!(InvalidCommitId::Empty.to_string(), "empty");
assert_eq!(InvalidCommitId::NotACommitId.to_string(), "not a commit id");
}
#[test]
fn invalid_sub_path_displays_each_message() {
assert_eq!(InvalidSubPath::Empty.to_string(), "empty");
assert_eq!(
InvalidSubPath::OutsideRepository.to_string(),
"must stay inside the repository"
);
}
#[test]
fn invalid_local_path_displays_each_message() {
assert_eq!(InvalidLocalPath::Empty.to_string(), "empty");
assert_eq!(
InvalidLocalPath::AbsolutePath.to_string(),
"absolute paths are not portable"
);
assert_eq!(
InvalidLocalPath::OutsideProject.to_string(),
"must stay inside the project"
);
}
}