| 681 | #[test] |
| 682 | #[serial] |
| 683 | fn test_run_duplicate_view() { |
| 684 | use tempfile::tempdir; |
| 685 | |
| 686 | let _guard = DirGuard::new(); |
| 687 | let temp = tempdir().unwrap(); |
| 688 | let repo_path = temp.path(); |
| 689 | |
| 690 | // Initialize a repository and drop to release lock |
| 691 | { |
| 692 | let _repo = Repository::init(repo_path).unwrap(); |
| 693 | } |
| 694 | |
| 695 | // Change to the repo directory |
| 696 | std::env::set_current_dir(repo_path).unwrap(); |
| 697 | |
| 698 | // Create the view first time |
| 699 | let cmd = New::with_name("duplicate"); |
| 700 | assert!(cmd.run().is_ok()); |
| 701 | |
| 702 | // Try to create it again |
| 703 | let cmd = New::with_name("duplicate"); |
| 704 | let result = cmd.run(); |
| 705 | assert!(result.is_err()); |
| 706 | match result.unwrap_err() { |
| 707 | CliError::ViewAlreadyExists { name } => { |
| 708 | assert_eq!(name, "duplicate"); |
| 709 | } |
| 710 | other => panic!("Expected ViewAlreadyExists, got: {:?}", other), |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | #[test] |
| 715 | #[serial] |