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

Function test_git_fetch_repository

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

Source from the content-addressed store, hash-verified

359
360 #[test]
361 fn test_git_fetch_repository() {
362 let repo_dir = DirectoryForTests::new_with_random_suffix("/tmp/tmp_git".to_string());
363 let repo_path = repo_dir.path();
364 let commit = "9a9c1f4373c8128151a9def9ea3d838fa2ed33e8";
365
366 // We only allow https:// at the moment
367 let repo = fetch(
368 &Url::parse("ssh://git@github.com/Qovery/engine.git").unwrap(),
369 &repo_path,
370 &|_| vec![],
371 commit,
372 );
373 assert!(matches!(repo, Err(e) if e.message().contains("https://")));
374
375 // Repository must be empty
376 let repo = fetch(
377 &Url::parse("https://github.com/Qovery/engine-testing.git").unwrap(),
378 &repo_path,
379 &|_| vec![],
380 commit,
381 );
382 assert!(repo.is_ok()); // clone makes sure to empty the directory
383
384 // Working case
385 {
386 let clone_dir = DirectoryForTests::new_with_random_suffix("/tmp/engine_test_clone".to_string());
387 let repo = fetch(
388 &Url::parse("https://github.com/Qovery/engine-testing.git").unwrap(),
389 clone_dir.path(),
390 &|_| vec![],
391 commit,
392 );
393 assert!(matches!(repo, Ok(_repo)));
394 }
395
396 // Invalid credentials
397 {
398 let clone_dir = DirectoryForTests::new_with_random_suffix("/tmp/engine_test_clone".to_string());
399 let get_credentials = |_: &str| {
400 vec![(
401 CredentialType::USER_PASS_PLAINTEXT,
402 Cred::userpass_plaintext("FAKE", "FAKE").unwrap(),
403 )]
404 };
405 let repo = fetch(
406 &Url::parse("https://gitlab.com/qovery/q-core.git").unwrap(),
407 clone_dir.path(),
408 &get_credentials,
409 commit,
410 );
411 assert!(matches!(repo, Err(repo) if repo.message().contains("authentication")));
412 }
413
414 /*
415 // Test with bitbucket credentials
416 // This is a toy account feel free to trash it
417 {
418 let clone_dir = DirectoryToDelete {

Callers

nothing calls this directly

Calls 2

fetchFunction · 0.85
pathMethod · 0.45

Tested by

no test coverage detected