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