| 523 | #[test] |
| 524 | #[file_serial] |
| 525 | fn test_delete_current_view() { |
| 526 | use tempfile::tempdir; |
| 527 | |
| 528 | let _guard = DirGuard::new(); |
| 529 | let temp = tempdir().unwrap(); |
| 530 | let repo_path = temp.path(); |
| 531 | |
| 532 | // Initialize a repository (current view is "dev") and drop to release lock |
| 533 | { |
| 534 | let _repo = Repository::init(repo_path).unwrap(); |
| 535 | } |
| 536 | |
| 537 | // Change to the repo directory |
| 538 | std::env::set_current_dir(repo_path).unwrap(); |
| 539 | |
| 540 | // Try to delete the current view. The plain form routes through |
| 541 | // the service area (local backend by default): the domain's |
| 542 | // refusal rides the contract's error vocabulary. |
| 543 | let cmd = Delete::with_name("dev"); |
| 544 | let result = cmd.run(); |
| 545 | assert!(result.is_err()); |
| 546 | match result.unwrap_err() { |
| 547 | CliError::ServiceRefusal { message } => { |
| 548 | assert!( |
| 549 | message.contains("cannot delete the current view 'dev'"), |
| 550 | "unexpected refusal: {message}" |
| 551 | ); |
| 552 | } |
| 553 | other => panic!("Expected the current-view refusal, got: {:?}", other), |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | #[test] |
| 558 | #[file_serial] |