@@ -415,37 +415,30 @@ mod tests {
415415 write ! ( file, "{}" , content) . unwrap ( ) ;
416416 }
417417
418- #[ test]
419- fn matches_agent_pattern_works ( ) {
420- assert ! ( matches_agent_pattern( "agent/test.md" ) ) ;
421- assert ! ( matches_agent_pattern( "agents/test.md" ) ) ;
422- assert ! ( matches_agent_pattern( "agent/nested/deep.md" ) ) ;
423- assert ! ( matches_agent_pattern( "agents/nested/deep.md" ) ) ;
424- assert ! ( !matches_agent_pattern( "other/test.md" ) ) ;
425- assert ! ( !matches_agent_pattern( "agent/test.txt" ) ) ;
426- assert ! ( !matches_agent_pattern( "notagen/test.md" ) ) ;
418+ #[ rstest]
419+ #[ case:: agent_directory( "agent/test.md" , true ) ] // top-level agent/ path
420+ #[ case:: agents_directory( "agents/test.md" , true ) ] // top-level agents/ path
421+ #[ case:: nested_agent( "agent/nested/deep.md" , true ) ] // nested under agent/
422+ #[ case:: nested_agents( "agents/nested/deep.md" , true ) ] // nested under agents/
423+ #[ case:: wrong_directory( "other/test.md" , false ) ] // non-agent directory
424+ #[ case:: wrong_extension( "agent/test.txt" , false ) ] // non-.md extension
425+ #[ case:: wrong_prefix( "notagen/test.md" , false ) ] // similar prefix but not agent/
426+ fn agent_path_pattern_matching ( #[ case] rel_path : & str , #[ case] expected : bool ) {
427+ assert_eq ! ( matches_agent_pattern( rel_path) , expected) ;
427428 }
428429
429- #[ test]
430- fn derive_agent_name_from_rel_works ( ) {
431- assert_eq ! (
432- derive_agent_name_from_rel( "agent/test.md" ) ,
433- Some ( "test" . to_string( ) )
434- ) ;
435- assert_eq ! (
436- derive_agent_name_from_rel( "agents/test.md" ) ,
437- Some ( "test" . to_string( ) )
438- ) ;
439- assert_eq ! (
440- derive_agent_name_from_rel( "agent/nested/deep.md" ) ,
441- Some ( "nested/deep" . to_string( ) )
442- ) ;
430+ #[ rstest]
431+ #[ case:: agent_directory( "agent/test.md" , Some ( "test" ) ) ] // strips agent/ prefix
432+ #[ case:: agents_directory( "agents/test.md" , Some ( "test" ) ) ] // strips agents/ prefix
433+ #[ case:: nested_agent( "agent/nested/deep.md" , Some ( "nested/deep" ) ) ] // preserves nested path
434+ #[ case:: deep_nested( "agents/foo/bar/baz.md" , Some ( "foo/bar/baz" ) ) ] // deep nesting under agents/
435+ #[ case:: empty_name_agent( "agent/.md" , None ) ] // empty stem → no name
436+ #[ case:: empty_name_agents( "agents/.md" , None ) ] // empty stem → no name
437+ fn extracts_agent_name_from_rel_path ( #[ case] rel_path : & str , #[ case] expected : Option < & str > ) {
443438 assert_eq ! (
444- derive_agent_name_from_rel( "agents/foo/bar/baz.md" ) ,
445- Some ( "foo/bar/baz" . to_string( ) )
439+ derive_agent_name_from_rel( rel_path ) ,
440+ expected . map ( |s| s . to_string( ) )
446441 ) ;
447- assert_eq ! ( derive_agent_name_from_rel( "agent/.md" ) , None ) ;
448- assert_eq ! ( derive_agent_name_from_rel( "agents/.md" ) , None ) ;
449442 }
450443
451444 #[ test]
0 commit comments