mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-11-24 12:16:25 +00:00
34 lines
822 B
Rust
34 lines
822 B
Rust
use test_log::test;
|
|
|
|
use salsa::plumbing::ZalsaDatabase;
|
|
use salsa::{Durability, Setter};
|
|
|
|
#[salsa::input]
|
|
struct MyInput {
|
|
required_field: bool,
|
|
|
|
#[default]
|
|
optional_field: usize,
|
|
}
|
|
|
|
#[test]
|
|
fn execute() {
|
|
let mut db = salsa::DatabaseImpl::new();
|
|
|
|
let input = MyInput::builder(true)
|
|
.required_field_durability(Durability::HIGH)
|
|
.new(&db);
|
|
|
|
// Change the field value. It should preserve high durability.
|
|
input.set_required_field(&mut db).to(false);
|
|
|
|
let last_high_revision = db.zalsa().last_changed_revision(Durability::HIGH);
|
|
|
|
// Changing the value again should **again** dump the high durability revision.
|
|
input.set_required_field(&mut db).to(false);
|
|
|
|
assert_ne!(
|
|
db.zalsa().last_changed_revision(Durability::HIGH),
|
|
last_high_revision
|
|
);
|
|
}
|