@@ -727,6 +727,92 @@ void main() {
727727 );
728728 },
729729 );
730+
731+ test (
732+ 'installing completion for .bashrc' ,
733+ () {
734+ final bashInstallation = CompletionInstallation (
735+ logger: logger,
736+ isWindows: false ,
737+ environment: {
738+ 'HOME' : tempDir.path,
739+ },
740+ configuration: bashConfiguration,
741+ );
742+
743+ final configDir = bashInstallation.completionConfigDir;
744+
745+ final bashProfile = File (path.join (tempDir.path, '.bash_profile' ))
746+ ..createSync ();
747+
748+ bashInstallation.install ('very_good' );
749+
750+ // Different format needed for matching cli output
751+ expect (bashProfile.readAsStringSync (), '''
752+ \n ## [Completion]
753+ ## Completion scripts setup. Remove the following line to uninstall
754+ [ -f ${configDir .path }/bash-config.bash ] && . ${configDir .path }/bash-config.bash || true
755+ ## [/Completion]
756+
757+ ''' );
758+ },
759+ );
760+
761+ test (
762+ 'installing completion for .bash_profile' ,
763+ () {
764+ final bashInstallation = CompletionInstallation (
765+ logger: logger,
766+ isWindows: false ,
767+ environment: {
768+ 'HOME' : tempDir.path,
769+ },
770+ configuration: bashConfiguration,
771+ );
772+
773+ final configDir = bashInstallation.completionConfigDir;
774+
775+ final bashRc = File (path.join (tempDir.path, '.bashrc' ))..createSync ();
776+
777+ bashInstallation.install ('very_good' );
778+
779+ // Different format needed for matching cli output
780+ expect (bashRc.readAsStringSync (), '''
781+ \n ## [Completion]
782+ ## Completion scripts setup. Remove the following line to uninstall
783+ [ -f ${configDir .path }/bash-config.bash ] && . ${configDir .path }/bash-config.bash || true
784+ ## [/Completion]
785+
786+ ''' );
787+ },
788+ );
789+
790+ test (
791+ 'missing .bashrc and .bash_profile' ,
792+ () {
793+ final bashInstallation = CompletionInstallation (
794+ logger: logger,
795+ isWindows: false ,
796+ environment: {
797+ 'HOME' : tempDir.path,
798+ },
799+ configuration: bashConfiguration,
800+ );
801+
802+ expect (
803+ () => bashInstallation.install ('very_good' ),
804+ throwsA (
805+ isA <CompletionInstallationException >().having (
806+ (e) => e.message,
807+ 'message' ,
808+ 'No configuration files where found at '
809+ '\n ${path .join (tempDir .path , '.bashrc' )}'
810+ '\n ${path .join (tempDir .path , '.bash_profile' )}' ,
811+ ),
812+ ),
813+ );
814+ },
815+ );
730816 });
731817
732818 group ('uninstall' , () {
0 commit comments