mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
Implement test to check editor temporary filename
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
This commit is contained in:
parent
5d4d68fe32
commit
512fb63e1f
2 changed files with 12 additions and 3 deletions
|
@ -44,9 +44,9 @@ Feature: Journals iteracting with the file system in a way that users can see
|
|||
Given we use the config "editor.yaml"
|
||||
When we run "jrnl --edit"
|
||||
Then the editor should have been called
|
||||
Then the temporary filename suffix should be ".jrnl"
|
||||
Then the editor filename should end with ".jrnl"
|
||||
|
||||
Scenario: the temporary filename suffix should be "-{template_filename}"
|
||||
Given we use the config "editor_markdown_extension.yaml"
|
||||
When we run "jrnl --edit"
|
||||
Then the temporary filename suffix should be "-extension.md"
|
||||
Then the editor filename should end with "-extension.md"
|
||||
|
|
|
@ -141,11 +141,13 @@ def temp_dir():
|
|||
def working_dir(request):
|
||||
return os.path.join(request.config.rootpath, "tests")
|
||||
|
||||
|
||||
@fixture
|
||||
def config_path(temp_dir):
|
||||
os.chdir(temp_dir.name)
|
||||
return temp_dir.name + "/jrnl.yaml"
|
||||
|
||||
|
||||
@fixture
|
||||
def toml_version(working_dir):
|
||||
pyproject = os.path.join(working_dir, "..", "pyproject.toml")
|
||||
|
@ -201,7 +203,7 @@ def keyring_type():
|
|||
@fixture
|
||||
def config_data(config_path):
|
||||
return load_config(config_path)
|
||||
|
||||
|
||||
|
||||
@fixture
|
||||
def journal_name():
|
||||
|
@ -304,6 +306,13 @@ def count_editor_args(num_args, cli_run, editor_state):
|
|||
assert len(editor_state["command"]) == int(num_args)
|
||||
|
||||
|
||||
@then(parse('the editor filename should end with "{suffix}"'))
|
||||
def editor_filename_suffix(suffix, editor_state):
|
||||
editor_filename = editor_state["tmpfile"]["name"]
|
||||
|
||||
assert editor_state["tmpfile"]["name"].endswith(suffix), (editor_filename, suffix)
|
||||
|
||||
|
||||
@then(parse('the editor file content should {comparison} "{str_value}"'))
|
||||
@then(parse("the editor file content should {comparison} empty"))
|
||||
@then(parse("the editor file content should {comparison}\n{str_value}"))
|
||||
|
|
Loading…
Add table
Reference in a new issue