Add test for end of path is slash

This commit is contained in:
Jonathan van der Steege 2022-05-23 22:48:10 +02:00
parent e5470cf793
commit d694a283c7
3 changed files with 25 additions and 0 deletions

View file

@ -31,6 +31,14 @@ Feature: Journals iteracting with the file system in a way that users can see
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should contain "This is a new entry in my journal" Then the output should contain "This is a new entry in my journal"
Scenario: If the directory for a Folder journal ending in a slash ('/' or '\') doesn't exist, then it should be created
Given we use the config "missing_directory.yaml"
Then the journal "endslash" directory should not exist
When we run "jrnl endslash This is a new entry in my journal"
Then the journal "endslash" directory should exist
When we run "jrnl endslash -1"
Then the output should contain "This is a new entry in my journal"
Scenario: Creating journal with relative path should update to absolute path Scenario: Creating journal with relative path should update to absolute path
Given we use no config Given we use no config
When we run "jrnl hello world" and enter When we run "jrnl hello world" and enter

View file

@ -5,6 +5,7 @@ encrypt: false
highlight: true highlight: true
journals: journals:
default: features/journals/missing_directory/simple.journal default: features/journals/missing_directory/simple.journal
endslash: features/journals/missing_folder/
linewrap: 80 linewrap: 80
tagsymbols: "@" tagsymbols: "@"
template: false template: false

View file

@ -210,6 +210,22 @@ def journal_should_not_exist(config_on_disk, should_or_should_not):
) )
@then(parse('the journal "{journal_name}" directory {should_or_should_not} exist'))
def directory_should_not_exist(config_on_disk, should_or_should_not, journal_name):
scoped_config = scope_config(config_on_disk, journal_name)
expected_path = scoped_config["journal"]
dir_exists = os.path.isdir(expected_path)
if should_or_should_not == "should":
assert dir_exists
elif should_or_should_not == "should not":
assert not dir_exists
else:
raise Exception(
"should_or_should_not valid values are 'should' or 'should not'"
)
@then(parse('the content of file "{file_path}" in the cache should be\n{file_content}')) @then(parse('the content of file "{file_path}" in the cache should be\n{file_content}'))
def content_of_file_should_be(file_path, file_content, cache_dir): def content_of_file_should_be(file_path, file_content, cache_dir):
assert cache_dir["exists"] assert cache_dir["exists"]