Compare commits

..

No commits in common. "cb78c58de1d4b0985a5cf686225a6bd78f538d22" and "0a844c42ee7c6953d28cbf9442eb5f14609ea661" have entirely different histories.

2 changed files with 14 additions and 16 deletions

View File

@ -102,6 +102,7 @@ pub fn split_repo_without_tag(repo: &str) -> Result<Repo, Error> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::repo;
use crate::repo::{Error, Repo}; use crate::repo::{Error, Repo};
#[test] #[test]
@ -127,23 +128,23 @@ mod tests {
#[test] #[test]
fn test_match_yaml_image() { fn test_match_yaml_image() {
use crate::repo::match_yaml_image as test_fn; use crate::repo::match_yaml_image as test_fn;
assert_eq!(test_fn(""), Err(Error::NoTagFound)); assert_eq!(test_fn(""), None);
assert_eq!(test_fn("version: '2'"), Err(Error::NoTagFound)); assert_eq!(test_fn("version: '2'"), None);
assert_eq!(test_fn("image: "), Err(Error::NoTagFound)); assert_eq!(test_fn("image: "), None);
assert_eq!(test_fn(" image: "), Err(Error::NoTagFound)); assert_eq!(test_fn(" image: "), None);
assert_eq!(test_fn(" image: nginx"), Ok((" image: ", "nginx"))); assert_eq!(test_fn(" image: nginx"), Some((" image: ", "nginx")));
assert_eq!( assert_eq!(
test_fn(" image: library/nginx"), test_fn(" image: library/nginx"),
Ok((" image: ", "library/nginx")) Some((" image: ", "library/nginx"))
); );
assert_eq!( assert_eq!(
test_fn(" image: ghcr.io/library/nginx"), test_fn(" image: ghcr.io/library/nginx"),
Ok((" image: ", "ghcr.io/library/nginx")) Some((" image: ", "ghcr.io/library/nginx"))
); );
assert_eq!(test_fn("# image: nginx"), Err(Error::NoTagFound)); assert_eq!(test_fn("# image: nginx"), None);
assert_eq!( assert_eq!(
test_fn(" image: nginx #comment"), test_fn(" image: nginx #comment"),
Ok((" image: ", "nginx")) Some((" image: ", "nginx"))
); );
} }

View File

@ -13,7 +13,7 @@ struct ImageDetails {
impl fmt::Display for ImageDetails { impl fmt::Display for ImageDetails {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}|{}MB", self.architecture, self.size / 1024 / 1024) write!(f, "[{}, {}MB]", self.architecture, self.size / 1024 / 1024)
} }
} }
@ -122,19 +122,16 @@ impl fmt::Display for Images {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
//architecture infos //architecture infos
let mut arch = String::new(); let mut arch = String::new();
for image in self.images.iter().take(1) { for image in &self.images {
arch.push_str(&format!("{}", image)); arch.push_str(&format!("{}", image));
} }
for image in self.images.iter().skip(1) {
arch.push_str(&format!(", {}", image));
}
let now = chrono::Utc::now(); let now = chrono::Utc::now();
let rfc3339 = DateTime::parse_from_rfc3339(&self.last_updated).unwrap(); let rfc3339 = DateTime::parse_from_rfc3339(&self.last_updated).unwrap();
let dif = now - rfc3339.with_timezone(&chrono::Utc); let dif = now - rfc3339.with_timezone(&chrono::Utc);
write!( write!(
f, f,
"{} vor {} [{}]", "{} vor {} {}",
self.tag_name, self.tag_name,
format_time_nice(dif), format_time_nice(dif),
arch arch
@ -167,7 +164,7 @@ fn format_time_nice(time: chrono::Duration) -> String {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::tags::Tags; use crate::tags::{Error, Tags};
#[test] #[test]
fn test_check_repo() { fn test_check_repo() {
assert_eq!(Tags::check_repo("nginx").unwrap(), "library/nginx"); assert_eq!(Tags::check_repo("nginx").unwrap(), "library/nginx");