Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

update tests to use macro_db_migrator (#1274)

Will Hutchinsond0b3d49887f3
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index 710fb8eb79..31da73b74d 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -2665,6 +2665,7 @@ dependencies = [
"macro_aws_config",
"macro_cors",
"macro_db_client",
+ "macro_db_migrator",
"macro_entrypoint",
"macro_env",
"macro_middleware",
diff --git a/rust/cloud-storage/README.md b/rust/cloud-storage/README.md
index e75fda3b91..3379583086 100644
--- a/rust/cloud-storage/README.md
+++ b/rust/cloud-storage/README.md
@@ -28,7 +28,7 @@ To start with a fresh database in docker clear it with: `docker-compose down &&
## Deployment
-To learn more read the [infra](./infra/README.md) documentation.
+To learn more read the [infra](../../infra/README.md) documentation.
## Instructions
diff --git a/rust/cloud-storage/document_cognition_service/Cargo.toml b/rust/cloud-storage/document_cognition_service/Cargo.toml
index a1ead32002..db55fa40bb 100644
--- a/rust/cloud-storage/document_cognition_service/Cargo.toml
+++ b/rust/cloud-storage/document_cognition_service/Cargo.toml
@@ -108,3 +108,4 @@ uuid = { workspace = true }
[dev-dependencies]
macro_auth = { path = "../macro_auth", features = ["testing"] }
+macro_db_migrator = { path = "../macro_db_migrator" }
diff --git a/rust/cloud-storage/document_cognition_service/justfile b/rust/cloud-storage/document_cognition_service/justfile
index a982ed62a1..615b31a68d 100644
--- a/rust/cloud-storage/document_cognition_service/justfile
+++ b/rust/cloud-storage/document_cognition_service/justfile
@@ -36,9 +36,6 @@ create-queue:
purge-queue:
AWS_REGION=us-east-1 aws --endpoint-url=http://localhost:4566 sqs purge-queue --queue-url http://localhost:4566/000000000000/my-test-queue
-prepare-test:
- rm -rf ./migrations && cp -r ../macro_db_client/migrations ./
-
init_local_db *user_id:
bash scripts/init-local-dcs.sh "{{ user_id }}"
diff --git a/rust/cloud-storage/document_cognition_service/src/service/get_chat.rs b/rust/cloud-storage/document_cognition_service/src/service/get_chat.rs
index d6ffda31a6..5f7a668422 100644
--- a/rust/cloud-storage/document_cognition_service/src/service/get_chat.rs
+++ b/rust/cloud-storage/document_cognition_service/src/service/get_chat.rs
@@ -148,9 +148,13 @@ pub async fn get_chat(
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("chat_example")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("chat_example"))
+ )]
/// chat three has 2 messages,
/// it has 0 active attachments
/// but message-one has 3 message attachments
diff --git a/rust/cloud-storage/document_cognition_service/src/service/id_mapping/test.rs b/rust/cloud-storage/document_cognition_service/src/service/id_mapping/test.rs
index 3767298aa8..2508fcc2e7 100644
--- a/rust/cloud-storage/document_cognition_service/src/service/id_mapping/test.rs
+++ b/rust/cloud-storage/document_cognition_service/src/service/id_mapping/test.rs
@@ -1,7 +1,8 @@
use super::*;
+use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
-#[sqlx::test]
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
async fn test_create_and_get_id_mapping(pool: Pool<Postgres>) -> anyhow::Result<()> {
// Create a mapping
create_id_mapping(&pool, "source-123", "target-456").await?;
@@ -13,7 +14,7 @@ async fn test_create_and_get_id_mapping(pool: Pool<Postgres>) -> anyhow::Result<
Ok(())
}
-#[sqlx::test]
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
async fn test_get_nonexistent_mapping(pool: Pool<Postgres>) -> anyhow::Result<()> {
let target = get_id_mapping(&pool, "nonexistent").await?;
assert_eq!(target, None);
@@ -21,7 +22,7 @@ async fn test_get_nonexistent_mapping(pool: Pool<Postgres>) -> anyhow::Result<()
Ok(())
}
-#[sqlx::test]
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
async fn test_upsert_id_mapping(pool: Pool<Postgres>) -> anyhow::Result<()> {
// Create initial mapping
create_id_mapping(&pool, "source-abc", "target-old").await?;
diff --git a/rust/cloud-storage/justfile b/rust/cloud-storage/justfile
index e39ad73f26..5750d3acc4 100644
--- a/rust/cloud-storage/justfile
+++ b/rust/cloud-storage/justfile
@@ -83,6 +83,5 @@ setup_test_envs:
setup_macrodb:
just macro_db_client/create_db
just macro_db_client/migrate_db
- just document_cognition_service/prepare-test
initialize_dbs: setup_macrodb