Skip to content

Commit

Permalink
test: test for child applied and grand children applied
Browse files Browse the repository at this point in the history
Signed-off-by: Saurav Sharma <[email protected]>
  • Loading branch information
iamsauravsharma committed Mar 24, 2024
1 parent 0d5a648 commit 3507320
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/migrator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,36 @@ async fn loop_error() {
assert!(plan.is_err());
}

#[tokio::test]
async fn child_before_parent() {
struct A;
migration!(A, "a", vec_box!(), vec_box!(), vec_box!());
struct B;
migration!(B, "b", vec_box!(A), vec_box!(), vec_box!());
let mut migrator = CustomMigrator::default();
migrator.add_applied_migrations(vec_box!(B));
let plan = generate_apply_all_plan(&mut migrator, vec_box!(A, B)).await;
assert!(plan.is_err());
}

#[tokio::test]
async fn replace_test_grand_child() {
struct A;
migration!(A, "a", vec_box!(), vec_box!(), vec_box!());
struct B;
migration!(B, "b", vec_box!(A), vec_box!(), vec_box!());
struct C;
migration!(C, "c", vec_box!(), vec_box!(B), vec_box!());
struct D;
migration!(D, "d", vec_box!(), vec_box!(C), vec_box!());
let mut migrator = CustomMigrator::default();
migrator.add_applied_migrations(vec_box!(A, D));
let plan = generate_apply_all_plan(&mut migrator, vec_box!(D, C, B, A))
.await
.unwrap();
assert!(plan.is_empty());
}

#[tokio::test]
async fn apply_plan_size_test() {
struct A;
Expand Down

0 comments on commit 3507320

Please sign in to comment.