caretta-sync/macros/tests/derive_syncable.rs

35 lines
812 B
Rust
Raw Normal View History

use chrono::Local;
2025-06-28 08:04:32 +09:00
use sea_orm::{
prelude::*,
entity::{
*,
prelude::*
}
};
2025-08-05 08:17:35 +09:00
use caretta_core::data::syncable::*;
use caretta_macros::SyncableModel;
2025-06-28 08:04:32 +09:00
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, SyncableModel)]
#[sea_orm(table_name = "syncable")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
#[syncable(id)]
pub id: Uuid,
#[sea_orm(indexed)]
#[syncable(timestamp)]
pub created_at: DateTimeUtc,
#[syncable(author_id)]
2025-06-28 08:04:32 +09:00
pub created_by: Uuid,
}
#[derive(Copy, Clone, Debug, DeriveRelation, EnumIter)]
pub enum Relation{}
impl ActiveModelBehavior for ActiveModel {}
2025-06-28 08:04:32 +09:00
#[test]
fn test_columns() {
assert!(Column::Id.is_id());
assert!(Column::CreatedAt.is_timestamp());
assert!(Column::CreatedBy.is_author_id());
}