git flow was a mistake #11

Merged
cafkafk merged 29 commits from dev into main 2023-08-09 16:27:57 +02:00
2 changed files with 74 additions and 4 deletions
Showing only changes of commit 78f3aa5a1d - Show all commits

View file

@ -355,10 +355,22 @@ impl Repo {
// fs::remove_dir_all(format!("{}{}", &self.path.as_ref(), &self.name.as_ref()))
}
fn check_is_valid_gitrepo(&self) -> bool {
// pub name: string,
// pub path: string,
// pub url: string,
todo!();
if (self.name.is_none()) {
eprintln!("{:?} must have name: <string>", self.kind);
return false;
}
if (self.path.is_none()) {
eprintln!("{:?} must have path: <string>", self.kind);
return false;
}
if (self.url.is_none()) {
eprintln!("{:?} must have url: <string>", self.kind);
return false;
}
assert!(self.name.is_some());
assert!(self.path.is_some());
assert!(self.url.is_some());
true
}
fn check_is_valid_githubrepo(&self) -> bool {
todo!();

View file

@ -276,6 +276,64 @@ mod config {
});
}
}
#[test]
fn test_validators_config() {
use crate::git::SeriesItem;
let root = current_dir().expect("failed to get current dir");
let config = Config::new(
&RelativePath::new("./src/test/config.yaml")
.to_logical_path(&root)
.into_os_string()
.into_string()
.expect("failed to turn config into string"),
);
let series: Vec<SeriesItem> = vec![SeriesItem {
operation: "is_valid_kind",
closure: Box::new(Repo::is_valid_kind),
}];
run_series!(config, series, true);
}
#[test]
#[should_panic]
fn test_validators_fail() {
use crate::git::SeriesItem;
let default_category = Category {
flags: Some(vec![]),
repos: Some(HashMap::new()),
links: Some(HashMap::new()),
};
let mut config = Config {
categories: HashMap::new(),
};
config
.categories
.insert(format!("{}", 0).to_string(), default_category);
for i in 0..=5 {
config
.categories
.get_mut(&format!("{}", 0).to_string())
.expect("category not found")
.repos
.as_mut()
.expect("failed to get repo")
.insert(
format!("{}", i).to_string(),
// WE create a broken repo
Repo {
name: None,
path: Some("/tmp".to_string()),
url: Some("https://github.com/cafkafk/gg".to_string()),
flags: Some(vec![Clone, Push]),
kind: Some(crate::git::RepoKinds::GitRepo),
},
);
}
let series: Vec<SeriesItem> = vec![SeriesItem {
operation: "is_valid_kind",
closure: Box::new(Repo::is_valid_kind),
}];
run_series!(config, series, true);
}
}
/* FIXME Unable to test with networking inside flake