| 1 | module main |
| 2 | |
| 3 | import os |
| 4 | import git |
| 5 | |
| 6 | fn test_read_clone_progress_hides_initial_bare_clone_message() { |
| 7 | progress_path := os.join_path(os.temp_dir(), 'gitly_clone_progress_${os.getpid()}.log') |
| 8 | os.write_file(progress_path, |
| 9 | "Cloning into bare repository './repos/medvednikov/v4'...\nremote: Enumerating objects: 251249, done.\nReceiving objects: 31% (78861/251249), 54.49 MiB | 3.59 MiB/s")! |
| 10 | defer { |
| 11 | os.rm(progress_path) or {} |
| 12 | } |
| 13 | |
| 14 | assert read_clone_progress(progress_path) == 'remote: Enumerating objects: 251249, done.\nReceiving objects: 31% (78861/251249), 54.49 MiB | 3.59 MiB/s' |
| 15 | } |
| 16 | |
| 17 | fn test_clone_size_limit_marker_is_detected_and_hidden_from_progress() { |
| 18 | progress_path := os.join_path(os.temp_dir(), 'gitly_clone_size_limit_${os.getpid()}.log') |
| 19 | os.write_file(progress_path, |
| 20 | 'Receiving objects: 100% (10/10), 100.00 MiB | 2.00 MiB/s\n${git.clone_size_limit_marker}\n')! |
| 21 | defer { |
| 22 | os.rm(progress_path) or {} |
| 23 | } |
| 24 | |
| 25 | assert clone_size_limit_failed(progress_path) |
| 26 | assert read_clone_progress(progress_path) == 'Receiving objects: 100% (10/10), 100.00 MiB | 2.00 MiB/s' |
| 27 | } |
| 28 | |
| 29 | fn test_clone_size_limit_is_only_for_non_admin_not_self_hosted_instances() { |
| 30 | assert should_enforce_clone_size_limit(false, true) |
| 31 | assert !should_enforce_clone_size_limit(true, true) |
| 32 | assert !should_enforce_clone_size_limit(false, false) |
| 33 | assert !should_enforce_clone_size_limit(true, false) |
| 34 | } |
| 35 | |