@@ -903,4 +903,72 @@ mod tests {
903903 assert ! ( fresh_home. join( "env.fish" ) . exists( ) , "env.fish file should be created" ) ;
904904 assert ! ( fresh_home. join( "env.ps1" ) . exists( ) , "env.ps1 file should be created" ) ;
905905 }
906+
907+ #[ tokio:: test]
908+ async fn test_generate_completion_scripts_creates_all_files ( ) {
909+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
910+ let home = AbsolutePathBuf :: new ( temp_dir. path ( ) . to_path_buf ( ) ) . unwrap ( ) ;
911+
912+ generate_completion_scripts ( & home) . await . unwrap ( ) ;
913+
914+ let completion_dir = home. join ( "completion" ) ;
915+
916+ // Verify all completion scripts are created
917+ let bash_completion = completion_dir. join ( "vp.bash" ) ;
918+ let zsh_completion = completion_dir. join ( "_vp" ) ;
919+ let fish_completion = completion_dir. join ( "vp.fish" ) ;
920+ let ps1_completion = completion_dir. join ( "vp.ps1" ) ;
921+
922+ assert ! ( bash_completion. as_path( ) . exists( ) , "bash completion (vp.bash) should be created" ) ;
923+ assert ! ( zsh_completion. as_path( ) . exists( ) , "zsh completion (_vp) should be created" ) ;
924+ assert ! ( fish_completion. as_path( ) . exists( ) , "fish completion (vp.fish) should be created" ) ;
925+ assert ! (
926+ ps1_completion. as_path( ) . exists( ) ,
927+ "PowerShell completion (vp.ps1) should be created"
928+ ) ;
929+ }
930+
931+ #[ tokio:: test]
932+ async fn test_create_env_files_contains_completion ( ) {
933+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
934+ let home = AbsolutePathBuf :: new ( temp_dir. path ( ) . to_path_buf ( ) ) . unwrap ( ) ;
935+ let _guard = home_guard ( temp_dir. path ( ) ) ;
936+
937+ create_env_files ( & home) . await . unwrap ( ) ;
938+
939+ let env_content = tokio:: fs:: read_to_string ( home. join ( "env" ) ) . await . unwrap ( ) ;
940+ let fish_content = tokio:: fs:: read_to_string ( home. join ( "env.fish" ) ) . await . unwrap ( ) ;
941+ let ps1_content = tokio:: fs:: read_to_string ( home. join ( "env.ps1" ) ) . await . unwrap ( ) ;
942+
943+ assert ! (
944+ env_content. contains( "Shell completion" )
945+ && env_content. contains( "/completion/vp.bash\" " ) ,
946+ "env file should contain bash completion"
947+ ) ;
948+ assert ! (
949+ fish_content. contains( "Shell completion" )
950+ && fish_content. contains( "/completion/vp.fish\" " ) ,
951+ "env.fish file should contain fish completion"
952+ ) ;
953+ assert ! (
954+ ps1_content. contains( "Shell completion" )
955+ && ps1_content. contains( "/completion/vp.ps1\" " ) ,
956+ "env.ps1 file should contain PowerShell completion"
957+ ) ;
958+
959+ // Verify placeholders are replaced
960+ assert ! (
961+ !env_content. contains( "__VP_COMPLETION_BASH__" )
962+ && !env_content. contains( "__VP_COMPLETION_ZSH__" ) ,
963+ "env file should not contain __VP_COMPLETION_* placeholders"
964+ ) ;
965+ assert ! (
966+ !fish_content. contains( "__VP_COMPLETION_FISH__" ) ,
967+ "env.fish file should not contain __VP_COMPLETION_FISH__ placeholder"
968+ ) ;
969+ assert ! (
970+ !ps1_content. contains( "__VP_COMPLETION_PS1__" ) ,
971+ "env.ps1 file should not contain __VP_COMPLETION_PS1__ placeholder"
972+ ) ;
973+ }
906974}
0 commit comments