Skip to content

Commit

Permalink
refactor: move migrations (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
gusinacio authored Nov 13, 2024
1 parent 304cc56 commit b0d2cd8
Show file tree
Hide file tree
Showing 23 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/license_headers_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ jobs:
-ignore '.github/*.yml' \
-ignore '.github/workflows/*.yaml' \
-ignore '.github/*.yaml' \
-ignore 'crates/migrations/*.sql' \
-ignore 'migrations/*.sql' \
.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Install sqlx
run: cargo install sqlx-cli --no-default-features --features postgres
- name: Run the test sqlx migrations
run: cargo sqlx migrate run --source crates/migrations
run: cargo sqlx migrate run
- name: Check that the sqlx prepared query metadata is up-to-date
run: cargo sqlx prepare --workspace --check -- --all-targets --all-features

Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
- name: Install sqlx
run: cargo install sqlx-cli --no-default-features --features postgres
- name: Run the test sqlx migrations
run: cargo sqlx migrate run --source crates/migrations
run: cargo sqlx migrate run
- name: Run tests and generate coverage report
run: cargo llvm-cov test --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage to Coveralls
Expand Down Expand Up @@ -172,6 +172,6 @@ jobs:
- name: Install sqlx
run: cargo install sqlx-cli --no-default-features --features postgres
- name: Run the test sqlx migrations
run: cargo sqlx migrate run --source crates/migrations
run: cargo sqlx migrate run
- name: Test documentation code snippets
run: cargo test --doc --all-features --workspace
8 changes: 4 additions & 4 deletions crates/common/src/cost_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub(crate) mod test {
]
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn success_cost_models(pool: PgPool) {
let test_models = test_data();
let test_deployments = test_models
Expand Down Expand Up @@ -312,7 +312,7 @@ pub(crate) mod test {
}
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn global_fallback_cost_models(pool: PgPool) {
let test_models = test_data();
let test_deployments = test_models
Expand Down Expand Up @@ -403,7 +403,7 @@ pub(crate) mod test {
assert_eq!(missing_model.model, global_model.model);
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn success_cost_model(pool: PgPool) {
add_cost_models(&pool, to_db_models(test_data())).await;

Expand All @@ -425,7 +425,7 @@ pub(crate) mod test {
assert_eq!(model.model, Some("default => 0.00025;".to_string()));
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn global_fallback_cost_model(pool: PgPool) {
let test_models = test_data();
let global_model = global_cost_model();
Expand Down
4 changes: 2 additions & 2 deletions crates/common/src/tap/checks/deny_list_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ mod tests {
.await
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_sender_denylist(pgpool: PgPool) {
// Add the sender to the denylist
sqlx::query!(
Expand Down Expand Up @@ -253,7 +253,7 @@ mod tests {
.is_err());
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_sender_denylist_updates(pgpool: PgPool) {
let allocation_id = Address::from_str(ALLOCATION_ID).unwrap();
let signed_receipt =
Expand Down
18 changes: 9 additions & 9 deletions crates/common/src/tap/checks/value_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,13 @@ mod tests {

use super::MinimumValue;

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn initialize_check(pgpool: PgPool) {
let check = MinimumValue::new(pgpool, Duration::from_secs(0)).await;
assert_eq!(check.cost_model_map.read().unwrap().len(), 0);
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn should_initialize_check_with_models(pgpool: PgPool) {
// insert 2 cost models for different deployment_id
let test_models = crate::cost_model::test::test_data();
Expand All @@ -381,7 +381,7 @@ mod tests {
assert!(check.global_model.read().unwrap().is_none());
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn should_watch_model_insert(pgpool: PgPool) {
let check = MinimumValue::new(pgpool.clone(), Duration::from_secs(0)).await;
assert_eq!(check.cost_model_map.read().unwrap().len(), 0);
Expand All @@ -397,7 +397,7 @@ mod tests {
);
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn should_watch_model_remove(pgpool: PgPool) {
// insert 2 cost models for different deployment_id
let test_models = crate::cost_model::test::test_data();
Expand All @@ -417,7 +417,7 @@ mod tests {
assert_eq!(check.cost_model_map.read().unwrap().len(), 0);
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn should_start_global_model(pgpool: PgPool) {
let global_model = global_cost_model();
add_cost_models(&pgpool, vec![global_model.clone()]).await;
Expand All @@ -426,7 +426,7 @@ mod tests {
assert!(check.global_model.read().unwrap().is_some());
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn should_watch_global_model(pgpool: PgPool) {
let check = MinimumValue::new(pgpool.clone(), Duration::from_secs(0)).await;

Expand All @@ -437,7 +437,7 @@ mod tests {
assert!(check.global_model.read().unwrap().is_some());
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn should_remove_global_model(pgpool: PgPool) {
let global_model = global_cost_model();
add_cost_models(&pgpool, vec![global_model.clone()]).await;
Expand All @@ -457,7 +457,7 @@ mod tests {

const ALLOCATION_ID: Address = address!("deadbeefcafebabedeadbeefcafebabedeadbeef");

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn should_check_minimal_value(pgpool: PgPool) {
// insert cost models for different deployment_id
let test_models = crate::cost_model::test::test_data();
Expand Down Expand Up @@ -531,7 +531,7 @@ mod tests {
.expect("should accept more than minimal");
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn should_check_using_global(pgpool: PgPool) {
// insert cost models for different deployment_id
let test_models = crate::cost_model::test::test_data();
Expand Down
28 changes: 14 additions & 14 deletions crates/tap-agent/src/agent/sender_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ pub mod tests {
(sender, handle, prefix, escrow_accounts_tx)
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_update_allocation_ids(pgpool: PgPool) {
// Start a mock graphql server using wiremock
let mock_server = MockServer::start().await;
Expand Down Expand Up @@ -1293,7 +1293,7 @@ pub mod tests {
handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_new_allocation_id(pgpool: PgPool) {
// Start a mock graphql server using wiremock
let mock_server = MockServer::start().await;
Expand Down Expand Up @@ -1560,7 +1560,7 @@ pub mod tests {
.as_nanos() as u64
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_update_receipt_fees_no_rav(pgpool: PgPool) {
let (sender_account, handle, prefix, _) = create_sender_account(
pgpool,
Expand Down Expand Up @@ -1604,7 +1604,7 @@ pub mod tests {
handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_update_receipt_fees_trigger_rav(pgpool: PgPool) {
let (sender_account, handle, prefix, _) = create_sender_account(
pgpool,
Expand Down Expand Up @@ -1665,7 +1665,7 @@ pub mod tests {
handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_counter_greater_limit_trigger_rav(pgpool: PgPool) {
let (sender_account, handle, prefix, _) = create_sender_account(
pgpool,
Expand Down Expand Up @@ -1732,7 +1732,7 @@ pub mod tests {
handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_remove_sender_account(pgpool: PgPool) {
let (mock_escrow_subgraph_server, _mock_ecrow_subgraph) = mock_escrow_subgraph().await;
let (sender_account, handle, prefix, _) = create_sender_account(
Expand Down Expand Up @@ -1769,7 +1769,7 @@ pub mod tests {
}

/// Test that the deny status is correctly loaded from the DB at the start of the actor
#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_init_deny(pgpool: PgPool) {
sqlx::query!(
r#"
Expand Down Expand Up @@ -1803,7 +1803,7 @@ pub mod tests {
assert!(deny);
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_retry_unaggregated_fees(pgpool: PgPool) {
// we set to zero to block the sender, no matter the fee
let max_unaggregated_fees_per_sender: u128 = 0;
Expand Down Expand Up @@ -1856,7 +1856,7 @@ pub mod tests {
handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_deny_allow(pgpool: PgPool) {
async fn get_deny_status(sender_account: &ActorRef<SenderAccountMessage>) -> bool {
call!(sender_account, SenderAccountMessage::GetDeny).unwrap()
Expand Down Expand Up @@ -1956,7 +1956,7 @@ pub mod tests {
handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_initialization_with_pending_ravs_over_the_limit(pgpool: PgPool) {
// add last non-final ravs
let signed_rav = create_rav(*ALLOCATION_ID_0, SIGNER.0.clone(), 4, ESCROW_VALUE);
Expand All @@ -1982,7 +1982,7 @@ pub mod tests {
handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_unaggregated_fees_over_balance(pgpool: PgPool) {
// add last non-final ravs
let signed_rav = create_rav(*ALLOCATION_ID_0, SIGNER.0.clone(), 4, ESCROW_VALUE / 2);
Expand Down Expand Up @@ -2078,7 +2078,7 @@ pub mod tests {
handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_pending_rav_already_redeemed_and_redeem(pgpool: PgPool) {
// Start a mock graphql server using wiremock
let mock_server = MockServer::start().await;
Expand Down Expand Up @@ -2156,7 +2156,7 @@ pub mod tests {
handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_thawing_deposit_process(pgpool: PgPool) {
// add last non-final ravs
let signed_rav = create_rav(*ALLOCATION_ID_0, SIGNER.0.clone(), 4, ESCROW_VALUE / 2);
Expand Down Expand Up @@ -2208,7 +2208,7 @@ pub mod tests {
handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_sender_denied_close_allocation_stop_retry(pgpool: PgPool) {
// we set to 1 to block the sender on a really low value
let max_unaggregated_fees_per_sender: u128 = 1;
Expand Down
12 changes: 6 additions & 6 deletions crates/tap-agent/src/agent/sender_accounts_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ mod tests {
)
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_create_sender_accounts_manager(pgpool: PgPool) {
let (_, (actor, join_handle)) = create_sender_accounts_manager(pgpool).await;
actor.stop_and_wait(None, None).await.unwrap();
Expand Down Expand Up @@ -708,7 +708,7 @@ mod tests {
)
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_pending_sender_allocations(pgpool: PgPool) {
let (_, state) = create_state(pgpool.clone()).await;

Expand All @@ -732,7 +732,7 @@ mod tests {
assert_eq!(pending_allocation_id.get(&SENDER.1).unwrap().len(), 2);
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_update_sender_allocation(pgpool: PgPool) {
let (prefix, (actor, join_handle)) = create_sender_accounts_manager(pgpool).await;

Expand Down Expand Up @@ -766,7 +766,7 @@ mod tests {
join_handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_create_sender_account(pgpool: PgPool) {
struct DummyActor;
#[async_trait::async_trait]
Expand Down Expand Up @@ -803,7 +803,7 @@ mod tests {
handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_deny_sender_account_on_failure(pgpool: PgPool) {
struct DummyActor;
#[async_trait::async_trait]
Expand Down Expand Up @@ -857,7 +857,7 @@ mod tests {
handle.await.unwrap();
}

#[sqlx::test(migrations = "../migrations")]
#[sqlx::test(migrations = "../../migrations")]
async fn test_receive_notifications_(pgpool: PgPool) {
let prefix = format!(
"test-{}",
Expand Down
Loading

0 comments on commit b0d2cd8

Please sign in to comment.