use super::select;
use crate::git_tree::tests::fixture::Fixture;
use crate::projects::join::JoinState;
use crate::start::{BallSpec, Payload};
use tempfile::tempdir;
fn ball(tags: &[&str]) -> Payload {
Payload::Ball {
project: "dev/proj".to_owned(),
ball: BallSpec::Existing {
id: "bl-1111".to_owned(),
title: "t".to_owned(),
body: "b".to_owned(),
join: JoinState::ReadyStartable,
tags: tags.iter().map(|t| (*t).to_owned()).collect(),
},
}
}
#[test]
fn a_tag_naming_a_lineage_selects_it() {
let fx = Fixture::new();
fx.config_off("deep", "config/default");
assert_eq!(select(&fx.path, &ball(&["deep"])), Some("deep".to_owned()));
}
#[test]
fn the_first_tag_naming_a_lineage_wins() {
let fx = Fixture::new();
fx.config_off("deep", "config/default");
fx.config_off("quick", "config/default");
assert_eq!(
select(&fx.path, &ball(&["missing", "quick", "deep"])),
Some("quick".to_owned()),
);
}
#[test]
fn a_tag_naming_no_lineage_selects_the_default() {
let fx = Fixture::new();
assert_eq!(select(&fx.path, &ball(&["deep"])), None);
}
#[test]
fn an_untagged_ball_and_the_tagless_rungs_are_one_case() {
let fx = Fixture::new();
fx.config_off("deep", "config/default");
assert_eq!(select(&fx.path, &ball(&[])), None);
assert_eq!(select(&fx.path, &Payload::Bare), None);
assert_eq!(
select(
&fx.path,
&Payload::Ball {
project: "dev/proj".to_owned(),
ball: BallSpec::New {
title: "t".to_owned(),
body: "b".to_owned(),
},
},
),
None,
);
}
#[test]
fn a_workspace_with_no_repository_selects_the_default() {
let dir = tempdir().unwrap();
assert_eq!(select(dir.path(), &ball(&["deep"])), None);
}