Skip to content

Commit

Permalink
vicky/test: rewrite task creations with task builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Kek5chen committed Apr 24, 2024
1 parent 752496f commit 40f9053
Showing 1 changed file with 12 additions and 40 deletions.
52 changes: 12 additions & 40 deletions vicky/src/bin/vicky/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,54 +274,26 @@ pub async fn tasks_add(
mod tests {
use crate::tasks::check_lock_conflict;
use uuid::Uuid;
use vickylib::documents::{FlakeRef, Lock, Task, TaskStatus};
use vickylib::documents::{FlakeRef, Lock, Task, TaskBuilder, TaskStatus};

#[test]
fn add_new_conflicting_task() {
let task = Task {
id: Uuid::new_v4(),
display_name: String::from("Test 1"),
status: TaskStatus::NEW,
locks: vec![
Lock::READ {
name: String::from("mauz"),
},
Lock::WRITE {
name: String::from("mauz"),
},
],
flake_ref: FlakeRef {
flake: String::from(""),
args: vec![],
},
features: vec![],
};
let task = Task::builder()
.with_display_name("Test 1")
.with_read_lock("mauz")
.with_write_lock("mauz")
.build();
assert!(check_lock_conflict(&task))
}

#[test]
fn add_new_not_conflicting_task() {
let task = Task {
id: Uuid::new_v4(),
display_name: String::from("Test 1"),
status: TaskStatus::NEW,
locks: vec![
Lock::READ {
name: String::from("mauz"),
},
Lock::READ {
name: String::from("mauz"),
},
Lock::WRITE {
name: String::from("delete_everything"),
},
],
flake_ref: FlakeRef {
flake: String::from(""),
args: vec![],
},
features: vec![],
};
let task = Task::builder()
.with_display_name("Test 1")
.with_read_lock("mauz")
.with_read_lock("mauz")
.with_write_lock("delete_everything")
.build();
assert!(!check_lock_conflict(&task))
}
}

0 comments on commit 40f9053

Please sign in to comment.