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