trying to rework database migrations
This commit is contained in:
@@ -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?)
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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?;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user