cartulary 0.3.0-alpha.1

The knowledge layer of your project — decisions, issues, docs, all in one place.
Documentation
use crate::domain::model::temporal::timestamp::Timestamp;
use serde::Serialize;

use super::EventAction;

/// A single entry in the history log of a record.
///
/// Only the timestamp and the action are stored. Author and free-text notes
/// are available via git commit metadata.
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct Event {
    pub timestamp: Timestamp,
    pub action: EventAction,
}

#[cfg(test)]
pub mod strategy {
    use super::Event;
    use crate::domain::model::event::event_action::strategy::event_action;
    use crate::domain::model::temporal::timestamp::strategy::timestamp;
    use proptest::prelude::*;

    /// Generate an arbitrary `Event` from leaf strategies.
    pub fn event() -> impl Strategy<Value = Event> {
        (timestamp(), event_action()).prop_map(|(timestamp, action)| Event { timestamp, action })
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use proptest::prelude::*;

    proptest! {
        #[test]
        fn event_round_trips_through_clone(e in strategy::event()) {
            prop_assert_eq!(e.clone(), e);
        }
    }
}