feat(config): add centralized configuration constants and infrastructure tests
- Introduce config.rs with all magic numbers and resource limits defined as constants - Add comprehensive test suite covering metrics rendering, rate limiting, and cache operations - Include tests for configuration constant validation and sanitization functions - Add pack protocol tests for index_pack and pack_objects functionality - Implement remote repository discovery tests with security validations - Support runtime overrides via environment variables for all configurable values
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
mod common;
|
||||
|
||||
use gitks::pb::*;
|
||||
use tokio_stream::StreamExt;
|
||||
|
||||
fn hdr() -> RepositoryHeader {
|
||||
RepositoryHeader {
|
||||
relative_path: "test-repo".into(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_index_pack_empty_data() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let result = gb.index_pack(vec![IndexPackRequest {
|
||||
repository: Some(hdr()),
|
||||
data: vec![],
|
||||
done: false,
|
||||
strict: false,
|
||||
keep: false,
|
||||
}]);
|
||||
assert!(result.is_err());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_pack_objects_all() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
|
||||
let mut stream = gb
|
||||
.pack_objects(PackObjectsRequest {
|
||||
repository: Some(hdr()),
|
||||
options: None,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut total_bytes = 0usize;
|
||||
let mut has_error = false;
|
||||
while let Some(chunk) = stream.next().await {
|
||||
match chunk {
|
||||
Ok(c) => total_bytes += c.data.len(),
|
||||
Err(_) => has_error = true,
|
||||
}
|
||||
}
|
||||
assert!(!has_error, "pack_objects stream had errors");
|
||||
assert!(total_bytes > 0, "pack_objects produced no data");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user