Skip to content

Commit 8d95d01

Browse files
committed
test: verify anvil-index.json generation in CLI integration test
1 parent da7c64b commit 8d95d01

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

anvil/tests/cli.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,16 @@ async fn test_cli_hf_ingestion() {
307307
let dest = format!("s3://{}/{}", bucket_name, object_key);
308308
let output = run_cli(&["object", "head", &dest], config_dir.path()).await;
309309
assert!(output.status.success());
310+
311+
// Verify anvil-index.json
312+
let index_key = format!("{}/anvil-index.json", repo);
313+
let index_dest = format!("s3://{}/{}", bucket_name, index_key);
314+
let output = run_cli(&["object", "get", &index_dest], config_dir.path()).await;
315+
assert!(output.status.success(), "Failed to get anvil-index.json");
316+
let stdout = String::from_utf8(output.stdout).unwrap();
317+
let index_json: serde_json::Value = serde_json::from_str(&stdout).expect("Failed to parse anvil-index.json");
318+
319+
assert_eq!(index_json["meta"]["source_repo"], repo);
320+
assert_eq!(index_json["meta"]["total_files"], 1);
321+
assert!(index_json["files"][file].is_object());
310322
}

anvil/tests/hf_ingestion_e2e.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,35 @@ async fn hf_ingestion_config_json() {
267267
let txt = resp.text().await.unwrap();
268268
let v: serde_json::Value = serde_json::from_str(&txt).unwrap();
269269
assert!(v.is_object());
270+
271+
// Verify anvil-index.json
272+
let index_url = "http://localhost:50051/models/gpt-oss-20b/anvil-index.json";
273+
let index_resp = reqwest::get(index_url).await.unwrap();
274+
assert_eq!(index_resp.status(), 200, "anvil-index.json should be accessible");
275+
let index_txt = index_resp.text().await.unwrap();
276+
let index_v: serde_json::Value = serde_json::from_str(&index_txt).unwrap();
277+
278+
// Assert meta fields
279+
assert_eq!(index_v["meta"]["source_repo"], "openai/gpt-oss-20b");
280+
assert_eq!(index_v["meta"]["revision"], "main");
281+
assert_eq!(index_v["meta"]["total_files"], 1);
282+
assert!(index_v["meta"]["total_bytes"].is_number());
283+
assert!(index_v["meta"]["generated_at"].is_string());
284+
285+
// Assert files entry
286+
let files_map = index_v["files"].as_object().unwrap();
287+
assert_eq!(files_map.len(), 1);
288+
assert!(files_map.contains_key("config.json"));
289+
290+
let config_json_entry = files_map["config.json"].as_object().unwrap();
291+
assert!(config_json_entry.contains_key("size"));
292+
assert!(config_json_entry["size"].is_number());
293+
assert!(config_json_entry.contains_key("etag"));
294+
assert!(config_json_entry["etag"].is_string());
295+
assert!(config_json_entry.contains_key("last_modified"));
296+
assert!(config_json_entry["last_modified"].is_string());
297+
298+
// The size in anvil-index.json should match the actual file size.
299+
let expected_config_size = txt.len() as i64;
300+
assert_eq!(config_json_entry["size"].as_i64().unwrap(), expected_config_size);
270301
}

0 commit comments

Comments
 (0)