| 919 | |
| 920 | #[test] |
| 921 | fn test_init_fails_if_repository_exists() { |
| 922 | let temp = TempDir::new().unwrap(); |
| 923 | |
| 924 | // First init should succeed |
| 925 | let init1 = Init::at_path(temp.path()); |
| 926 | let result1 = init1.run(); |
| 927 | if let Err(ref e) = result1 { |
| 928 | eprintln!("First init failed: {:?}", e); |
| 929 | } |
| 930 | assert!( |
| 931 | result1.is_ok(), |
| 932 | "First init should succeed: {:?}", |
| 933 | result1.err() |
| 934 | ); |
| 935 | |
| 936 | // Second init should fail |
| 937 | let init2 = Init::at_path(temp.path()); |
| 938 | let result = init2.run(); |
| 939 | assert!(result.is_err()); |
| 940 | assert!(matches!( |
| 941 | result.unwrap_err(), |
| 942 | CliError::RepositoryExists { .. } |
| 943 | )); |
| 944 | } |
| 945 | |
| 946 | #[test] |
| 947 | fn test_init_with_custom_view() { |