diff --git a/src/cmd/check.rs b/src/cmd/check.rs index f6dd657..06db079 100644 --- a/src/cmd/check.rs +++ b/src/cmd/check.rs @@ -24,6 +24,7 @@ pub enum OsedaCheckError { BadGitCredentials(String), DirectoryNameMismatch(String), CouldNotPingLocalPresentation(String), + MissingDescription(String) } impl std::error::Error for OsedaCheckError {} @@ -41,6 +42,9 @@ impl std::fmt::Display for OsedaCheckError { Self::CouldNotPingLocalPresentation(msg) => { write!(f, "Could not ping localhost after project was ran {}", msg) } + Self::MissingDescription(msg) => { + write!(f, "Config file is missing description {}", msg) + } } } } diff --git a/src/config.rs b/src/config.rs index 1c79160..81416f5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -95,6 +95,13 @@ pub fn validate_config( )); } + if conf.description.is_empty() { + return Err(OsedaCheckError::MissingDescription( + "Description is missing or empty. Please update the oseda-config.json".to_owned(), + )) + } + + Ok(()) } @@ -107,6 +114,7 @@ pub struct OsedaConfig { // effectively mutable. Will get updated on each deployment pub last_updated: DateTime, pub color: String, + // description must not be empty for check/deploy pub description: String } @@ -281,7 +289,7 @@ mod test { tags: vec![Tag::ComputerScience], last_updated: chrono::Utc::now(), color: Color::Black.into_hex(), - description: String::new(), + description: String::from("Test Description"), }; let fake_dir = Path::new("/tmp/my-project"); @@ -299,7 +307,7 @@ mod test { tags: vec![Tag::ComputerScience], last_updated: chrono::Utc::now(), color: Color::Black.into_hex(), - description: String::new(), + description: String::from("Test Description"), }; let fake_dir = Path::new("/tmp/oseda"); @@ -337,7 +345,7 @@ mod test { tags: vec![Tag::ComputerScience], last_updated: chrono::Utc::now(), color: Color::Black.into_hex(), - description: String::new(), + description: String::from("Test Description"), }; let fake_dir = Path::new("/tmp/oseda");