MCPcopy Create free account
hub / github.com/Qovery/engine / test_git_file_content_at_commit

Function test_git_file_content_at_commit

lib-engine/src/cmd/git.rs:507–538  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

505
506 #[test]
507 fn test_git_file_content_at_commit() {
508 let repo_dir = DirectoryForTests::new_with_random_suffix("/tmp/engine_test_git_file".to_string());
509 let repo = Repository::init(repo_dir.path()).expect("repository should initialize");
510 let workdir = repo.workdir().expect("workdir should exist").to_path_buf();
511
512 fs::create_dir_all(workdir.join("clusters")).expect("directory should be created");
513 fs::write(
514 workdir.join("clusters/cluster-a.yaml"),
515 "kind: Cluster\nmetadata:\n name: test\n",
516 )
517 .expect("file should be written");
518
519 let mut index = repo.index().expect("index should open");
520 index
521 .add_path(Path::new("clusters/cluster-a.yaml"))
522 .expect("file should be staged");
523 index.write().expect("index should be written");
524 let tree_id = index.write_tree().expect("tree should be written");
525 let tree = repo.find_tree(tree_id).expect("tree should be found");
526 let signature = Signature::now("Qovery", "qovery@example.com").expect("signature should be created");
527 let commit_id = repo
528 .commit(Some("HEAD"), &signature, &signature, "initial commit", &tree, &[])
529 .expect("commit should be created");
530
531 let content = file_content_at_commit(&repo, &commit_id.to_string(), Path::new("clusters/cluster-a.yaml"))
532 .expect("file should be read from commit");
533
534 assert_eq!(
535 String::from_utf8(content).expect("content should be utf-8"),
536 "kind: Cluster\nmetadata:\n name: test\n"
537 );
538 }
539
540 #[test]
541 fn test_git_submodule_with_ssh_key() {

Callers

nothing calls this directly

Calls 4

initFunction · 0.85
file_content_at_commitFunction · 0.85
writeMethod · 0.80
pathMethod · 0.45

Tested by

no test coverage detected