Files
keep/src/tests/db/meta_tests.rs
Andrew Phillips 49793a0f94 feat: add streaming tar export/import and rename "none" to "raw"
- Add streaming tar-based export (--export produces .keep.tar)
- Add streaming tar import (--import reads .keep.tar archives)
- Add server endpoints GET /api/export and POST /api/import
- Rename CompressionType::None to CompressionType::Raw with "none" as alias
- Add DB migration to update existing "none" compression values to "raw"
- Fix export endpoint to propagate errors to client instead of swallowing
- Fix import endpoint to return 413 on max_body_size instead of truncating

Export streams items as tar archives without loading entire files into memory.
Import extracts items with new IDs, preserving original order. Both work
locally and via client/server mode.

Co-Authored-By: opencode <noreply@opencode.ai>
2026-03-17 21:24:39 -03:00

39 lines
1.2 KiB
Rust

#[cfg(test)]
mod tests {
use crate::db;
use crate::db::Meta;
use crate::tests::common::test_helpers::{create_temp_db, create_test_item};
#[test]
fn test_database_meta_operations() {
// Create a temporary database
let (_temp_dir, conn, _db_path) = create_temp_db();
// First insert an item to have a valid ID
let item_id = create_test_item(&conn);
// Create a test meta with the valid item ID
let meta = Meta {
id: item_id,
name: "test_key".to_string(),
value: "test_value".to_string(),
};
// Try to insert meta
let insert_result = db::query_upsert_meta(&conn, meta.clone());
assert!(insert_result.is_ok());
// Try to get meta for non-existent item
let item = crate::db::Item {
id: Some(999), // Non-existent item
ts: chrono::Utc::now(),
size: Some(0),
compression: crate::compression_engine::CompressionType::Raw.to_string(),
};
let metas = db::get_item_meta(&conn, &item);
assert!(metas.is_ok());
assert_eq!(metas.unwrap().len(), 0);
}
}