trying to rework database migrations

This commit is contained in:
2026-02-05 11:42:04 -06:00
parent 3b14c65998
commit 343488b3eb
83 changed files with 5793 additions and 876 deletions

View File

@@ -434,6 +434,7 @@ pub async fn create_test_pack(pool: &PgPool, ref_name: &str) -> Result<Pack> {
tags: vec!["test".to_string()],
runtime_deps: vec![],
is_standard: false,
installers: json!({}),
};
Ok(PackRepository::create(pool, input).await?)

View File

@@ -12,7 +12,7 @@ mod helpers;
use attune_common::{
models::Pack,
pack_registry::calculate_directory_checksum,
repositories::{pack::PackRepository, pack_installation::PackInstallationRepository, List},
repositories::{pack::PackRepository, List},
};
use helpers::{Result, TestContext};
use serde_json::json;
@@ -351,19 +351,18 @@ async fn test_install_pack_metadata_tracking() -> Result<()> {
let pack_id = body["data"]["pack"]["id"].as_i64().unwrap();
// Verify installation metadata was created
let installation_repo = PackInstallationRepository::new(ctx.pool.clone());
let installation = installation_repo
.get_by_pack_id(pack_id)
let pack = PackRepository::find_by_id(&ctx.pool, pack_id)
.await?
.expect("Should have installation record");
.expect("Should have pack record");
assert_eq!(installation.pack_id, pack_id);
assert_eq!(installation.source_type, "local_directory");
assert!(installation.source_url.is_some());
assert!(installation.checksum.is_some());
assert_eq!(pack.id, pack_id);
assert_eq!(pack.source_type.as_deref(), Some("local_directory"));
assert!(pack.source_url.is_some());
assert!(pack.checksum.is_some());
assert!(pack.installed_at.is_some());
// Verify checksum matches
let stored_checksum = installation.checksum.as_ref().unwrap();
let stored_checksum = pack.checksum.as_ref().unwrap();
assert_eq!(
stored_checksum, &original_checksum,
"Stored checksum should match calculated checksum"
@@ -451,13 +450,14 @@ async fn test_install_pack_storage_path_created() -> Result<()> {
let pack_id = body["data"]["pack"]["id"].as_i64().unwrap();
// Verify installation metadata has storage path
let installation_repo = PackInstallationRepository::new(ctx.pool.clone());
let installation = installation_repo
.get_by_pack_id(pack_id)
let pack = PackRepository::find_by_id(&ctx.pool, pack_id)
.await?
.expect("Should have installation record");
.expect("Should have pack record");
let storage_path = &installation.storage_path;
let storage_path = pack
.storage_path
.as_ref()
.expect("Should have storage path");
assert!(
storage_path.contains("storage-test"),
"Storage path should contain pack ref"

View File

@@ -42,6 +42,7 @@ async fn setup_test_pack_and_action(pool: &PgPool) -> Result<(Pack, Action)> {
tags: vec!["test".to_string()],
runtime_deps: vec![],
is_standard: false,
installers: json!({}),
};
let pack = PackRepository::create(pool, pack_input).await?;

View File

@@ -40,6 +40,7 @@ async fn create_test_pack(state: &AppState, name: &str) -> i64 {
tags: vec![],
runtime_deps: vec![],
is_standard: false,
installers: json!({}),
};
let pack = PackRepository::create(&state.db, input)

View File

@@ -48,6 +48,7 @@ async fn create_test_pack(state: &AppState, name: &str) -> i64 {
tags: vec![],
runtime_deps: vec![],
is_standard: false,
installers: json!({}),
};
let pack = PackRepository::create(&state.db, input)