(db: &DatabaseConnection)
| 18 | } |
| 19 | |
| 20 | pub async fn create_and_update(db: &DatabaseConnection) -> Result<(), DbErr> { |
| 21 | let bits = bits::Model { |
| 22 | id: 1, |
| 23 | bit0: 0, |
| 24 | bit1: 1, |
| 25 | bit8: 8, |
| 26 | bit16: 16, |
| 27 | bit32: 32, |
| 28 | bit64: 64, |
| 29 | }; |
| 30 | |
| 31 | let res = bits.clone().into_active_model().insert(db).await?; |
| 32 | |
| 33 | let model = Bits::find().one(db).await?; |
| 34 | assert_eq!(model, Some(res)); |
| 35 | assert_eq!(model, Some(bits.clone())); |
| 36 | |
| 37 | let res = bits::ActiveModel { |
| 38 | bit32: Set(320), |
| 39 | bit64: Set(640), |
| 40 | ..bits.clone().into_active_model() |
| 41 | } |
| 42 | .update(db) |
| 43 | .await?; |
| 44 | |
| 45 | let model = Bits::find().one(db).await?; |
| 46 | assert_eq!(model, Some(res)); |
| 47 | assert_eq!( |
| 48 | model, |
| 49 | Some(bits::Model { |
| 50 | id: 1, |
| 51 | bit0: 0, |
| 52 | bit1: 1, |
| 53 | bit8: 8, |
| 54 | bit16: 16, |
| 55 | bit32: 320, |
| 56 | bit64: 640, |
| 57 | }) |
| 58 | ); |
| 59 | |
| 60 | Ok(()) |
| 61 | } |
no test coverage detected