MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / test_create_build_context_tar

Function test_create_build_context_tar

crates/openshell-bootstrap/src/build.rs:470–495  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

468
469 #[test]
470 fn test_create_build_context_tar() {
471 let dir = tempfile::tempdir().unwrap();
472 let dir_path = dir.path();
473
474 // Create a simple Dockerfile and a file.
475 fs::write(dir_path.join("Dockerfile"), "FROM ubuntu:24.04\n").unwrap();
476 fs::write(dir_path.join("hello.txt"), "hello world\n").unwrap();
477 fs::create_dir(dir_path.join("subdir")).unwrap();
478 fs::write(dir_path.join("subdir/nested.txt"), "nested\n").unwrap();
479
480 let tar_bytes = create_build_context_tar(dir_path).unwrap();
481 assert!(!tar_bytes.is_empty());
482
483 // Verify the tar contains the expected entries.
484 let mut archive = tar::Archive::new(tar_bytes.as_slice());
485 let entries: Vec<String> = archive
486 .entries()
487 .unwrap()
488 .filter_map(std::result::Result::ok)
489 .map(|e| e.path().unwrap().to_string_lossy().to_string())
490 .collect();
491
492 assert!(entries.iter().any(|e| e.contains("Dockerfile")));
493 assert!(entries.iter().any(|e| e.contains("hello.txt")));
494 assert!(entries.iter().any(|e| e.contains("subdir/nested.txt")));
495 }
496
497 #[test]
498 fn test_dockerignore_excludes_files() {

Callers

nothing calls this directly

Calls 3

create_build_context_tarFunction · 0.85
pathMethod · 0.80
as_sliceMethod · 0.80

Tested by

no test coverage detected