Skip to content

Commit 0661e2f

Browse files
committed
adding test
1 parent 02db915 commit 0661e2f

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

test/src/command_runner_test.dart

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,10 @@ void main() {
194194

195195
stdout = _MockStdout();
196196
when(() => stdout.hasTerminal).thenReturn(true);
197-
when(() => stdout.supportsAnsiEscapes).thenReturn(true);
197+
198198
when(() => stdout.terminalColumns).thenReturn(30);
199+
200+
when(() => stdout.supportsAnsiEscapes).thenReturn(true);
199201
});
200202

201203
test('shows message when version changed', () async {
@@ -269,6 +271,32 @@ void main() {
269271
);
270272
});
271273

274+
test('fallback to HOME when XDG_CONFIG_HOME is null/empty', () async {
275+
commandRunner
276+
..environmentOverride = {
277+
'HOME': '/users/test',
278+
'XDG_CONFIG_HOME': '',
279+
}
280+
..isWindowsOverride = false;
281+
282+
final homeCache = _MockDirectory();
283+
when(() => homeCache.path).thenReturn('/users/test');
284+
285+
await IOOverrides.runZoned(
286+
() async {
287+
final result = await commandRunner.run([]);
288+
expect(result, equals(ExitCode.success.code));
289+
290+
verifyNever(() => cliCache.path);
291+
verify(() => homeCache.path).called(1);
292+
},
293+
createDirectory: (path) =>
294+
path.contains('test') ? homeCache : cliCache,
295+
createFile: (path) => versionFile,
296+
stdout: () => stdout,
297+
);
298+
});
299+
272300
test('cache inside local APP_DATA on windows', () async {
273301
commandRunner
274302
..environmentOverride = {'LOCALAPPDATA': '/C/Users/test'}

0 commit comments

Comments
 (0)