summaryrefslogtreecommitdiffstats
path: root/tests/state_machine.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/state_machine.rs')
-rw-r--r--tests/state_machine.rs42
1 files changed, 5 insertions, 37 deletions
diff --git a/tests/state_machine.rs b/tests/state_machine.rs
index 70d7aa6..ccfdc42 100644
--- a/tests/state_machine.rs
+++ b/tests/state_machine.rs
@@ -2,6 +2,11 @@ mod common;
use aur_build::db::{builds, model::{BuildState, CandidateState, StepState}};
use common::Env;
+// What remains all moves real rows through real transitions against a
+// database. The two tests that were only about the state enum — the column-text
+// round trip and the shape of the transition table — moved into
+// src/db/model/build_state.rs, where the enum and its table are declared, and
+// so did the one pure table assertion that a fixture test was making.
fn build(env: &Env, id: &str) -> String {
env.exec(
@@ -18,15 +23,6 @@ fn state(env: &Env, id: &str) -> BuildState {
}
#[test]
-fn every_state_round_trips_through_its_column_text() {
- for s in BuildState::ALL {
- assert_eq!(BuildState::parse(s.as_str()), Some(*s), "{s:?} does not round-trip");
- }
- assert_eq!(BuildState::parse("exploded"), None);
- assert_eq!(BuildState::parse(""), None);
-}
-
-#[test]
fn the_machine_refuses_a_transition_it_does_not_define() {
let env = Env::new();
let id = build(&env, "b1");
@@ -50,10 +46,6 @@ fn a_terminal_build_is_history_and_does_not_move() {
assert_eq!(state(&env, "b1"), BuildState::Succeeded);
for to in [BuildState::Running, BuildState::Queued, BuildState::Failed] {
- assert!(
- !BuildState::Succeeded.can_transition(to),
- "succeeded must not transition to {to:?}"
- );
assert!(builds::set_state(&env.db, &id, to, None).is_err(), "accepted {to:?} after success");
}
assert_eq!(state(&env, "b1"), BuildState::Succeeded);
@@ -88,30 +80,6 @@ fn a_state_the_code_does_not_know_is_an_error_not_an_empty_string() {
}
#[test]
-fn the_transition_table_is_the_machine_the_code_actually_uses() {
- let reachable = |from: BuildState| -> Vec<&'static str> {
- BuildState::ALL
- .iter()
- .filter(|to| from.can_transition(**to))
- .map(|to| to.as_str())
- .collect()
- };
- assert_eq!(reachable(BuildState::Queued), ["queued", "leased", "running", "blocked_missing_dep", "cancelled"]);
- assert_eq!(
- reachable(BuildState::Leased),
- ["queued", "leased", "running", "blocked_missing_dep", "succeeded", "failed", "cancelled"]
- );
- assert_eq!(
- reachable(BuildState::Running),
- ["queued", "running", "blocked_missing_dep", "succeeded", "failed", "cancelled"]
- );
- assert_eq!(reachable(BuildState::BlockedMissingDep), ["queued", "blocked_missing_dep", "cancelled"]);
- assert_eq!(reachable(BuildState::Failed), ["queued", "running", "failed"]);
- assert_eq!(reachable(BuildState::Cancelled), ["queued", "cancelled"]);
- assert_eq!(reachable(BuildState::Succeeded), ["succeeded"]);
-}
-
-#[test]
fn requeueing_a_succeeded_build_is_refused_not_silently_requeued() {
let env = Env::new();
let id = build(&env, "b1");