File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33#[ cfg( test) ]
44mod tests {
55 use crate :: agent_cmd:: cli:: { CopyArgs , ExportArgs } ;
6- use crate :: agent_cmd:: loader:: {
7- load_builtin_agents, parse_frontmatter, read_file_with_encoding,
8- } ;
6+ use crate :: agent_cmd:: loader:: { load_builtin_agents, parse_frontmatter} ;
97 use crate :: agent_cmd:: types:: AgentMode ;
8+ use crate :: utils:: file:: read_file_with_encoding;
109
1110 #[ test]
1211 fn test_read_file_with_utf8 ( ) {
Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ use super::helpers::{
1818use super :: scheduler:: DagScheduler ;
1919use super :: types:: { DagOutputFormat , ExecutionStrategy } ;
2020
21+ pub ( super ) fn task_count_label ( count : usize ) -> String {
22+ if count == 1 {
23+ "1 task" . to_string ( )
24+ } else {
25+ format ! ( "{} tasks" , count)
26+ }
27+ }
28+
2129/// Create a DAG from specification.
2230pub async fn run_create ( args : DagCreateArgs ) -> Result < ( ) > {
2331 let spec = load_spec ( & args. file ) ?;
@@ -49,7 +57,11 @@ pub async fn run_create(args: DagCreateArgs) -> Result<()> {
4957
5058 match args. format {
5159 DagOutputFormat :: Text => {
52- print_success ( & format ! ( "✓ Created DAG '{}' with {} tasks" , id, dag. len( ) ) ) ;
60+ print_success ( & format ! (
61+ "✓ Created DAG '{}' with {}" ,
62+ id,
63+ task_count_label( dag. len( ) )
64+ ) ) ;
5365 println ! ( ) ;
5466 print_dag_summary ( & dag) ;
5567 }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use super::types::{DagSpecInput, TaskSpecInput};
55use cortex_agents:: task:: { DagHydrator , Task , TaskId , TaskSpec } ;
66use std:: collections:: HashMap ;
77
8+ use super :: commands:: task_count_label;
89use super :: executor:: TaskExecutor ;
910
1011#[ test]
@@ -78,6 +79,12 @@ fn test_dag_creation_with_cycle_detection() {
7879 assert ! ( result. is_err( ) ) ;
7980}
8081
82+ #[ test]
83+ fn test_dag_create_task_count_label_uses_singular_for_one_task ( ) {
84+ assert_eq ! ( task_count_label( 1 ) , "1 task" ) ;
85+ assert_eq ! ( task_count_label( 2 ) , "2 tasks" ) ;
86+ }
87+
8188#[ tokio:: test]
8289async fn test_task_executor ( ) {
8390 let executor = TaskExecutor :: new ( 30 , false ) ;
You can’t perform that action at this time.
0 commit comments