@@ -705,4 +705,44 @@ mod tests {
705705 let ty: syn:: Type = syn:: parse_str ( "Vec<DateTime<Utc>>" ) . unwrap ( ) ;
706706 assert ! ( is_primitive_like( & ty) ) ;
707707 }
708+
709+ // Tests for extract_module_path_from_schema_path
710+
711+ #[ rstest]
712+ #[ case( "crate :: models :: user :: Schema" , vec![ "crate" , "models" , "user" ] ) ]
713+ #[ case( "crate :: models :: nested :: deep :: Model" , vec![ "crate" , "models" , "nested" , "deep" ] ) ]
714+ #[ case( "super :: user :: Entity" , vec![ "super" , "user" ] ) ]
715+ #[ case( "super :: Model" , vec![ "super" ] ) ]
716+ #[ case( "Schema" , vec![ ] ) ]
717+ #[ case( "Model" , vec![ ] ) ]
718+ fn test_extract_module_path_from_schema_path (
719+ #[ case] path_str : & str ,
720+ #[ case] expected : Vec < & str > ,
721+ ) {
722+ let tokens: proc_macro2:: TokenStream = path_str. parse ( ) . unwrap ( ) ;
723+ let result = extract_module_path_from_schema_path ( & tokens) ;
724+ let expected: Vec < String > = expected. into_iter ( ) . map ( |s| s. to_string ( ) ) . collect ( ) ;
725+ assert_eq ! ( result, expected) ;
726+ }
727+
728+ #[ test]
729+ fn test_extract_module_path_from_schema_path_empty ( ) {
730+ let tokens = proc_macro2:: TokenStream :: new ( ) ;
731+ let result = extract_module_path_from_schema_path ( & tokens) ;
732+ assert ! ( result. is_empty( ) ) ;
733+ }
734+
735+ #[ test]
736+ fn test_extract_module_path_from_schema_path_with_generics ( ) {
737+ // Even with generics, should extract module path correctly
738+ let tokens: proc_macro2:: TokenStream =
739+ "crate :: models :: user :: Schema < T >" . parse ( ) . unwrap ( ) ;
740+ let result = extract_module_path_from_schema_path ( & tokens) ;
741+ // Note: The current implementation splits by "::" which may include generics in last segment
742+ // This test documents current behavior
743+ assert ! ( !result. is_empty( ) ) ;
744+ assert_eq ! ( result[ 0 ] , "crate" ) ;
745+ assert_eq ! ( result[ 1 ] , "models" ) ;
746+ assert_eq ! ( result[ 2 ] , "user" ) ;
747+ }
708748}
0 commit comments