Skip to content

Commit 577d271

Browse files
committed
Added tests and updated missing files message.
1 parent 617d79d commit 577d271

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

lib/src/installer/completion_installation.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ class CompletionInstallation {
275275
}
276276

277277

278+
final _missingFiles = <String>[];
278279
String? __shellRCFilePath;
279280
String get _shellRCFilePath {
280281
String? firstPath;
@@ -286,6 +287,7 @@ class CompletionInstallation {
286287
__shellRCFilePath = filePath;
287288
return __shellRCFilePath!;
288289
}
290+
_missingFiles.add(filePath);
289291
}
290292
__shellRCFilePath = firstPath;
291293
}
@@ -305,9 +307,16 @@ class CompletionInstallation {
305307

306308
final shellRCFile = File(_shellRCFilePath);
307309
if (!shellRCFile.existsSync()) {
310+
var message = '';
311+
if(_missingFiles.length > 1){
312+
message = 'No configuration files where found at '
313+
'\n ${_missingFiles.join('\n ')}';
314+
}else{
315+
message = 'No configuration file found at ${shellRCFile.path}';
316+
}
308317
throw CompletionInstallationException(
309318
rootCommand: rootCommand,
310-
message: 'No configuration file found at ${shellRCFile.path}',
319+
message: message,
311320
);
312321
}
313322

test/src/installer/completion_installation_test.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,38 @@ void main() {
794794
},
795795
);
796796

797+
test(
798+
'missing .bashrc and .bash_profile',
799+
() {
800+
801+
final bashInstallation = CompletionInstallation(
802+
logger: logger,
803+
isWindows: false,
804+
environment: {
805+
'HOME': tempDir.path,
806+
},
807+
configuration: bashConfiguration,
808+
);
809+
810+
final configDir = bashInstallation.completionConfigDir;
811+
812+
const exceptionsMessage = '';
813+
814+
expect(
815+
() => bashInstallation.install('very_good'),
816+
throwsA(
817+
isA<CompletionInstallationException>().having(
818+
(e) => e.message,
819+
'message',
820+
'No configuration files where found at '
821+
'\n ${path.join(tempDir.path, '.bashrc')}'
822+
'\n ${path.join(tempDir.path, '.bash_profile')}',
823+
),
824+
),
825+
);
826+
827+
},
828+
);
797829
});
798830

799831
group('uninstall', () {

0 commit comments

Comments
 (0)