MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / test_retry_task

Function test_retry_task

src/task_manager.rs:450–517  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

448
449 #[tokio::test]
450 async fn test_retry_task() {
451 // Set up test environment
452 let (config, test_repo, ctx) = setup_test_environment().await.unwrap();
453 let repo_root = test_repo.path().to_path_buf();
454
455 // Create a completed task to retry
456 let task_id = "abcd1234".to_string();
457 let task_dir_path = config.task_dir(&task_id);
458 let instructions_path = task_dir_path.join("instructions.md");
459
460 let completed_task = Task {
461 id: task_id.clone(),
462 repo_root: repo_root.clone(),
463 name: "original-task".to_string(),
464 task_type: "generic".to_string(),
465 instructions_file: instructions_path.to_string_lossy().to_string(),
466 branch_name: format!("tsk/{task_id}"),
467 status: TaskStatus::Complete,
468 copied_repo_path: Some(task_dir_path.join("repo")),
469 ..Task::test_default()
470 };
471
472 // Set up task directory with instructions
473 let instructions_content =
474 "# Original Task Instructions\n\nThis is the original task content.";
475 setup_task_directory(&config, &task_id, instructions_content)
476 .await
477 .unwrap();
478
479 // Add task via storage API
480 let storage = ctx.task_storage();
481 storage.add_task(completed_task).await.unwrap();
482
483 // Create TaskManager and retry the task
484 let task_manager = TaskManager::new(&ctx).unwrap();
485
486 let result = task_manager
487 .retry_task(&task_id, false, RetryOverrides::default(), &ctx)
488 .await;
489 assert!(result.is_ok(), "Failed to retry task: {result:?}");
490 let new_task_id = result.unwrap();
491
492 // Verify new task ID format (8 characters)
493 assert_eq!(new_task_id.len(), 8);
494
495 // Verify task was added to storage
496 let new_task = task_manager
497 .task_storage
498 .get_task(&new_task_id)
499 .await
500 .unwrap();
501 assert!(new_task.is_some());
502 let new_task = new_task.unwrap();
503 // Since we removed the "retry-" prefix, name should be the same as original
504 assert_eq!(new_task.name, "original-task");
505 assert_eq!(new_task.task_type, "generic");
506 assert_eq!(new_task.agent, "claude".to_string());
507 assert_eq!(new_task.status, TaskStatus::Queued);

Callers

nothing calls this directly

Calls 8

setup_test_environmentFunction · 0.85
setup_task_directoryFunction · 0.85
pathMethod · 0.80
task_dirMethod · 0.80
task_storageMethod · 0.80
add_taskMethod · 0.80
retry_taskMethod · 0.80
get_taskMethod · 0.80

Tested by

no test coverage detected