konservejo/tests/backup.rs
NotAShelf 133d392df7
tests: initial integration test setup
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I082de335ed2b2bf53d687d81db0901ef6a6a6964
2026-03-19 17:01:09 +03:00

56 lines
1.4 KiB
Rust

//! End-to-end backup flow integration test.
#![expect(clippy::expect_used)]
use konservejo::{
core::{pipeline::Pipeline, types::JobStatus},
storage::Storage,
};
mod common;
use common::{
MockRepo,
TestContext,
compute_hash,
create_test_archive,
load_config,
setup_mock_server,
};
#[tokio::test]
async fn test_backup_single_repository() {
let archive = create_test_archive("test-repo");
let expected_hash = compute_hash(&archive);
let repos = vec![MockRepo::new("test-org", "test-repo", archive)];
let (_server, mock_url) = setup_mock_server(repos).await;
let ctx = TestContext::new(mock_url);
ctx.write_config(&["test-org".to_string()], &[], 4, 1, 10);
let config = load_config(&ctx).expect("Failed to load config");
let pipeline = Pipeline::new(config)
.await
.expect("Failed to create pipeline");
let run_id = pipeline.run().await.expect("Backup failed");
let db_url = format!("sqlite://{}", ctx.db_path().display());
let storage = Storage::new(&db_url)
.await
.expect("Failed to connect to DB");
let jobs = storage
.list_jobs_by_run(&run_id)
.await
.expect("Failed to list jobs");
assert_eq!(jobs.len(), 1, "Should have exactly 1 job");
assert_eq!(
jobs[0].status,
JobStatus::Committed,
"Job should be committed"
);
assert_eq!(
jobs[0].artifact_hash.as_ref(),
expected_hash,
"Hash should match"
);
}