mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-11-24 20:20:26 +00:00
35 lines
822 B
Rust
35 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
|
||
|
);
|
||
|
}
|