Skip to content

Commit 34c7e05

Browse files
authored
Merge pull request #70 from oseda-dev/rh-check-missing-desc
Check for missing description
2 parents d3123d5 + 59ef31d commit 34c7e05

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/cmd/check.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub enum OsedaCheckError {
2424
BadGitCredentials(String),
2525
DirectoryNameMismatch(String),
2626
CouldNotPingLocalPresentation(String),
27+
MissingDescription(String)
2728
}
2829

2930
impl std::error::Error for OsedaCheckError {}
@@ -41,6 +42,9 @@ impl std::fmt::Display for OsedaCheckError {
4142
Self::CouldNotPingLocalPresentation(msg) => {
4243
write!(f, "Could not ping localhost after project was ran {}", msg)
4344
}
45+
Self::MissingDescription(msg) => {
46+
write!(f, "Config file is missing description {}", msg)
47+
}
4448
}
4549
}
4650
}

src/config.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ pub fn validate_config(
9595
));
9696
}
9797

98+
if conf.description.is_empty() {
99+
return Err(OsedaCheckError::MissingDescription(
100+
"Description is missing or empty. Please update the oseda-config.json".to_owned(),
101+
))
102+
}
103+
104+
98105
Ok(())
99106
}
100107

@@ -107,6 +114,7 @@ pub struct OsedaConfig {
107114
// effectively mutable. Will get updated on each deployment
108115
pub last_updated: DateTime<Utc>,
109116
pub color: String,
117+
// description must not be empty for check/deploy
110118
pub description: String
111119
}
112120

@@ -281,7 +289,7 @@ mod test {
281289
tags: vec![Tag::ComputerScience],
282290
last_updated: chrono::Utc::now(),
283291
color: Color::Black.into_hex(),
284-
description: String::new(),
292+
description: String::from("Test Description"),
285293
};
286294

287295
let fake_dir = Path::new("/tmp/my-project");
@@ -299,7 +307,7 @@ mod test {
299307
tags: vec![Tag::ComputerScience],
300308
last_updated: chrono::Utc::now(),
301309
color: Color::Black.into_hex(),
302-
description: String::new(),
310+
description: String::from("Test Description"),
303311
};
304312

305313
let fake_dir = Path::new("/tmp/oseda");
@@ -337,7 +345,7 @@ mod test {
337345
tags: vec![Tag::ComputerScience],
338346
last_updated: chrono::Utc::now(),
339347
color: Color::Black.into_hex(),
340-
description: String::new(),
348+
description: String::from("Test Description"),
341349
};
342350

343351
let fake_dir = Path::new("/tmp/oseda");

0 commit comments

Comments
 (0)