mod common;
use common::{LedgerDir, check_in, qctl};
use indoc::indoc;
use rstest::rstest;
const ONE_WRONG_VALUE: &str = indoc! {"
schema_version: 3
prefix: QCTL
active: null
queue:
- id: QCTL-002
title: A row a verb could act on
scope: qctl
outcome: Something is true.
blocked_by: []
acceptance: [It holds.]
archive:
- id: QCTL-001
title: Shipped
scope: qctl
completed: last Tuesday
outcome: It shipped.
evidence: [The tag exists.]
"};
#[rstest]
#[case::start(&["start", "QCTL-002"])]
#[case::add(&["add", "-t", "t", "-s", "s", "-o", "o", "-a", "a"])]
#[case::park(&[
"park",
"-t",
"t",
"-s",
"s",
"-o",
"o",
"--kind",
"research",
"--open",
"missing",
])]
#[case::promote(&["promote", "QCTL-002", "-a", "a"])]
fn a_verb_refuses_a_ledger_it_cannot_vouch_for(#[case] verb: &[&str]) {
let dir = LedgerDir::empty();
dir.write(ONE_WRONG_VALUE);
let path = dir.path.to_string_lossy().into_owned();
let args: Vec<&str> = verb.iter().copied().chain(["--file", &path]).collect();
let output = qctl(&args);
assert!(!output.status.success(), "the verb ran anyway");
assert_eq!(dir.read(), ONE_WRONG_VALUE, "the verb wrote to it anyway");
}
#[rstest]
#[case::a_plan_outside_the_repository(indoc! {"
schema_version: 3
prefix: QCTL
active: null
queue:
- id: QCTL-002
title: A row a verb could act on
scope: qctl
outcome: Something is true.
blocked_by: []
acceptance: [It holds.]
plan: ../elsewhere/plan.md
archive: []
"})]
#[case::a_completed_that_is_not_a_moment(ONE_WRONG_VALUE)]
#[case::the_version_this_one_replaced(indoc! {"
schema_version: 2
prefix: QCTL
active: null
queue:
- id: QCTL-002
title: A row a verb could act on
scope: qctl
outcome: Something is true.
blocked_by: []
acceptance: [It holds.]
archive: []
"})]
fn check_refuses_whatever_a_verb_refuses(#[case] ledger: &str) {
let dir = LedgerDir::empty();
dir.write(ledger);
let path = dir.path.to_string_lossy().into_owned();
let verb = qctl(&["start", "QCTL-002", "--file", &path]);
assert!(!verb.status.success(), "the verb accepted it");
let (ok, complaint) = check_in(&dir, ledger);
assert!(
!ok,
"the verb refused this and check did not:\n{ledger}\n{complaint}"
);
}
#[test]
fn archive_refuses_a_ledger_it_cannot_vouch_for() {
let dir = LedgerDir::empty();
dir.write(ONE_WRONG_VALUE);
let path = dir.path.to_string_lossy().into_owned();
let output = qctl(&["archive", "QCTL-002", "-e", "it shipped", "--file", &path]);
assert!(!output.status.success(), "the verb ran anyway");
assert_eq!(dir.read(), ONE_WRONG_VALUE, "the verb wrote to it anyway");
}