| 1048 | |
| 1049 | #[test] |
| 1050 | fn test_init_fails_if_repository_exists() { |
| 1051 | let temp = TempDir::new().unwrap(); |
| 1052 | |
| 1053 | // First init should succeed |
| 1054 | let init1 = Init::at_path(temp.path()); |
| 1055 | let result1 = init1.run(); |
| 1056 | if let Err(ref e) = result1 { |
| 1057 | eprintln!("First init failed: {:?}", e); |
| 1058 | } |
| 1059 | assert!( |
| 1060 | result1.is_ok(), |
| 1061 | "First init should succeed: {:?}", |
| 1062 | result1.err() |
| 1063 | ); |
| 1064 | |
| 1065 | // Second init should fail |
| 1066 | let init2 = Init::at_path(temp.path()); |
| 1067 | let result = init2.run(); |
| 1068 | assert!(result.is_err()); |
| 1069 | assert!(matches!( |
| 1070 | result.unwrap_err(), |
| 1071 | CliError::RepositoryExists { .. } |
| 1072 | )); |
| 1073 | } |
| 1074 | |
| 1075 | #[test] |
| 1076 | fn test_init_with_custom_view() { |