Update unit test

This commit is contained in:
Billy Chan 2021-07-20 11:48:19 +08:00 committed by Chris Tsang
parent daa0ed947d
commit f75fcd8fdf
6 changed files with 48 additions and 42 deletions

View File

@ -36,7 +36,6 @@ impl PrimaryKeyTrait for PrimaryKey {
#[derive(Copy, Clone, Debug, EnumIter)] #[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation { pub enum Relation {
CakeFilling,
Fruit, Fruit,
} }
@ -53,22 +52,24 @@ impl ColumnTrait for Column {
impl RelationTrait for Relation { impl RelationTrait for Relation {
fn def(&self) -> RelationDef { fn def(&self) -> RelationDef {
match self { match self {
Self::CakeFilling => Entity::has_many(super::cake_filling::Entity).into(),
Self::Fruit => Entity::has_many(super::fruit::Entity).into(), Self::Fruit => Entity::has_many(super::fruit::Entity).into(),
} }
} }
} }
impl Related<super::cake_filling::Entity> for Entity {
fn to() -> RelationDef {
Relation::CakeFilling.def()
}
}
impl Related<super::fruit::Entity> for Entity { impl Related<super::fruit::Entity> for Entity {
fn to() -> RelationDef { fn to() -> RelationDef {
Relation::Fruit.def() Relation::Fruit.def()
} }
} }
impl Related<super::filling::Entity> for Entity {
fn to() -> RelationDef {
super::cake_filling::Relation::Filling.def()
}
fn via() -> Option<RelationDef> {
Some(super::cake_filling::Relation::Cake.def().rev())
}
}
impl ActiveModelBehavior for ActiveModel {} impl ActiveModelBehavior for ActiveModel {}

View File

@ -35,9 +35,7 @@ impl PrimaryKeyTrait for PrimaryKey {
} }
#[derive(Copy, Clone, Debug, EnumIter)] #[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation { pub enum Relation {}
CakeFilling,
}
impl ColumnTrait for Column { impl ColumnTrait for Column {
type EntityName = Entity; type EntityName = Entity;
@ -52,14 +50,17 @@ impl ColumnTrait for Column {
impl RelationTrait for Relation { impl RelationTrait for Relation {
fn def(&self) -> RelationDef { fn def(&self) -> RelationDef {
match self { match self {
Self::CakeFilling => Entity::has_many(super::cake_filling::Entity).into(), _ => panic!("No RelationDef"),
} }
} }
} }
impl Related<super::cake_filling::Entity> for Entity { impl Related<super::cake::Entity> for Entity {
fn to() -> RelationDef { fn to() -> RelationDef {
Relation::CakeFilling.def() super::cake_filling::Relation::Cake.def()
}
fn via() -> Option<RelationDef> {
Some(super::cake_filling::Relation::Filling.def().rev())
} }
} }

View File

@ -36,7 +36,6 @@ impl PrimaryKeyTrait for PrimaryKey {
#[derive(Copy, Clone, Debug, EnumIter)] #[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation { pub enum Relation {
CakeFilling,
Fruit, Fruit,
} }
@ -53,22 +52,24 @@ impl ColumnTrait for Column {
impl RelationTrait for Relation { impl RelationTrait for Relation {
fn def(&self) -> RelationDef { fn def(&self) -> RelationDef {
match self { match self {
Self::CakeFilling => Entity::has_many(super::cake_filling::Entity).into(),
Self::Fruit => Entity::has_many(super::fruit::Entity).into(), Self::Fruit => Entity::has_many(super::fruit::Entity).into(),
} }
} }
} }
impl Related<super::cake_filling::Entity> for Entity {
fn to() -> RelationDef {
Relation::CakeFilling.def()
}
}
impl Related<super::fruit::Entity> for Entity { impl Related<super::fruit::Entity> for Entity {
fn to() -> RelationDef { fn to() -> RelationDef {
Relation::Fruit.def() Relation::Fruit.def()
} }
} }
impl Related<super::filling::Entity> for Entity {
fn to() -> RelationDef {
super::cake_filling::Relation::Filling.def()
}
fn via() -> Option<RelationDef> {
Some(super::cake_filling::Relation::Cake.def().rev())
}
}
impl ActiveModelBehavior for ActiveModel {} impl ActiveModelBehavior for ActiveModel {}

View File

@ -35,9 +35,7 @@ impl PrimaryKeyTrait for PrimaryKey {
} }
#[derive(Copy, Clone, Debug, EnumIter)] #[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation { pub enum Relation {}
CakeFilling,
}
impl ColumnTrait for Column { impl ColumnTrait for Column {
type EntityName = Entity; type EntityName = Entity;
@ -52,14 +50,17 @@ impl ColumnTrait for Column {
impl RelationTrait for Relation { impl RelationTrait for Relation {
fn def(&self) -> RelationDef { fn def(&self) -> RelationDef {
match self { match self {
Self::CakeFilling => Entity::has_many(super::cake_filling::Entity).into(), _ => panic!("No RelationDef"),
} }
} }
} }
impl Related<super::cake_filling::Entity> for Entity { impl Related<super::cake::Entity> for Entity {
fn to() -> RelationDef { fn to() -> RelationDef {
Relation::CakeFilling.def() super::cake_filling::Relation::Cake.def()
}
fn via() -> Option<RelationDef> {
Some(super::cake_filling::Relation::Filling.def().rev())
} }
} }

View File

@ -36,7 +36,6 @@ impl PrimaryKeyTrait for PrimaryKey {
#[derive(Copy, Clone, Debug, EnumIter)] #[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation { pub enum Relation {
CakeFilling,
Fruit, Fruit,
} }
@ -53,22 +52,24 @@ impl ColumnTrait for Column {
impl RelationTrait for Relation { impl RelationTrait for Relation {
fn def(&self) -> RelationDef { fn def(&self) -> RelationDef {
match self { match self {
Self::CakeFilling => Entity::has_many(super::cake_filling::Entity).into(),
Self::Fruit => Entity::has_many(super::fruit::Entity).into(), Self::Fruit => Entity::has_many(super::fruit::Entity).into(),
} }
} }
} }
impl Related<super::cake_filling::Entity> for Entity {
fn to() -> RelationDef {
Relation::CakeFilling.def()
}
}
impl Related<super::fruit::Entity> for Entity { impl Related<super::fruit::Entity> for Entity {
fn to() -> RelationDef { fn to() -> RelationDef {
Relation::Fruit.def() Relation::Fruit.def()
} }
} }
impl Related<super::filling::Entity> for Entity {
fn to() -> RelationDef {
super::cake_filling::Relation::Filling.def()
}
fn via() -> Option<RelationDef> {
Some(super::cake_filling::Relation::Cake.def().rev())
}
}
impl ActiveModelBehavior for ActiveModel {} impl ActiveModelBehavior for ActiveModel {}

View File

@ -35,9 +35,7 @@ impl PrimaryKeyTrait for PrimaryKey {
} }
#[derive(Copy, Clone, Debug, EnumIter)] #[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation { pub enum Relation {}
CakeFilling,
}
impl ColumnTrait for Column { impl ColumnTrait for Column {
type EntityName = Entity; type EntityName = Entity;
@ -52,14 +50,17 @@ impl ColumnTrait for Column {
impl RelationTrait for Relation { impl RelationTrait for Relation {
fn def(&self) -> RelationDef { fn def(&self) -> RelationDef {
match self { match self {
Self::CakeFilling => Entity::has_many(super::cake_filling::Entity).into(), _ => panic!("No RelationDef"),
} }
} }
} }
impl Related<super::cake_filling::Entity> for Entity { impl Related<super::cake::Entity> for Entity {
fn to() -> RelationDef { fn to() -> RelationDef {
Relation::CakeFilling.def() super::cake_filling::Relation::Cake.def()
}
fn via() -> Option<RelationDef> {
Some(super::cake_filling::Relation::Filling.def().rev())
} }
} }