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