Skip to content

Commit 77c45af

Browse files
committed
tmuxp ls: Update tests
1 parent 9e3b36c commit 77c45af

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

tests/test_cli.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import json
66
import os
7-
from pathlib import Path
7+
import pathlib
88

99
import pytest
1010

@@ -582,14 +582,32 @@ def check_cmd(config_arg):
582582

583583
assert 'file not found' in check_cmd('.tmuxp.json')
584584

585-
def test_ls_cli(monkeypatch, tmpdir):
586-
tmpdir.join('.tmuxp/session_1.yaml').ensure()
587-
tmpdir.join('.tmuxp/session_2.yaml').ensure()
588-
tmpdir.join('.tmuxp/session_3.json').ensure()
589585

586+
def test_ls_cli(monkeypatch, tmpdir):
590587
monkeypatch.setenv("HOME", str(tmpdir))
591588

592-
runner = CliRunner()
589+
filenames = [
590+
'.git/',
591+
'.gitignore/',
592+
'session_1.yaml',
593+
'session_2.yaml',
594+
'session_3.json',
595+
'session_4.txt',
596+
]
597+
598+
# should ignore:
599+
# - directories should be ignored
600+
# - extensions not covered in VALID_CONFIG_DIR_FILE_EXTENSIONS
601+
ignored_filenames = ['.git/', '.gitignore/', 'session_4.txt']
602+
stems = [pathlib.PurePath(f).stem for f in filenames if f not in ignored_filenames]
603+
604+
for filename in filenames:
605+
location = tmpdir.join('.tmuxp/{}'.format(filename))
606+
if filename.endswith('/'):
607+
location.ensure_dir()
608+
else:
609+
location.ensure()
593610

611+
runner = CliRunner()
594612
cli_output = runner.invoke(command_ls).output
595-
assert cli_output == 'session_1\nsession_2\nsession_3\n'
613+
assert cli_output == '\n'.join(stems) + '\n'

0 commit comments

Comments
 (0)