* adds find_with_linked test * WIP(related test) * mock related test done * complete relation test * loader update * find_with/also_related missing test case for empty from other side * comments fixup * revert loader test * related select test done * find with/also linked test cases * removed due to it being functionally same as the new one * fmt, remove excess import * improved model generation * issue related test case #1790 * added loader test cases and slight improvement to find_related/linked * miscellaneous changes * added empty insert, merge load_one test case * completed loader many to many test case, fmt * removed empty_insert test case for now * commented insert_test * added Cargo.toml for issue 1790's folder * buffed salvo version for ci(0.49 yanked) * revert version for salvo example
58 lines
1.7 KiB
Rust
58 lines
1.7 KiB
Rust
mod tests {
|
|
// currently ok
|
|
#[test]
|
|
fn insert_do_nothing_postgres() {
|
|
assert_eq!(
|
|
Insert::<cake::ActiveModel>::new()
|
|
.add(cake::Model {
|
|
id: 1,
|
|
name: "Apple Pie".to_owned(),
|
|
})
|
|
.on_conflict(OnConflict::new()
|
|
.do_nothing()
|
|
.to_owned()
|
|
)
|
|
.build(DbBackend::Postgres)
|
|
.to_string(),
|
|
r#"INSERT INTO "cake" ("id", "name") VALUES (1, 'Apple Pie') ON CONFLICT DO NOTHING"#,
|
|
);
|
|
}
|
|
|
|
//failed to run
|
|
#[test]
|
|
fn insert_do_nothing_mysql() {
|
|
assert_eq!(
|
|
Insert::<cake::ActiveModel>::new()
|
|
.add(cake::Model {
|
|
id: 1,
|
|
name: "Apple Pie".to_owned(),
|
|
})
|
|
.on_conflict(OnConflict::new()
|
|
.do_nothing()
|
|
.to_owned()
|
|
)
|
|
.build(DbBackend::Mysql)
|
|
.to_string(),
|
|
r#"INSERT IGNORE INTO "cake" ("id", "name") VALUES (1, 'Apple Pie')"#,
|
|
);
|
|
}
|
|
|
|
// currently ok
|
|
#[test]
|
|
fn insert_do_nothing() {
|
|
assert_eq!(
|
|
Insert::<cake::ActiveModel>::new()
|
|
.add(cake::Model {
|
|
id: 1,
|
|
name: "Apple Pie".to_owned(),
|
|
})
|
|
.on_conflict(OnConflict::new()
|
|
.do_nothing()
|
|
.to_owned()
|
|
)
|
|
.build(DbBackend::Sqlite)
|
|
.to_string(),
|
|
r#"INSERT IGNORE INTO "cake" ("id", "name") VALUES (1, 'Apple Pie')"#,
|
|
);
|
|
}
|
|
} |