Add test for empty stdin input

This commit is contained in:
Aaron Lichtman 2019-11-17 01:49:46 +01:00
parent 91dcb812d7
commit 455261c55e
No known key found for this signature in database
GPG key ID: 22368077DE9F9903
2 changed files with 18 additions and 1 deletions

View file

@ -20,12 +20,20 @@ Feature: Basic reading and writing to a journal
When we run "jrnl -n 1"
Then the output should contain "2013-07-23 09:00 A cold and stormy day."
# Note that the expected output is actually "[Nothing saved to file]" but due to mocking limitations, we expect no output here.
Scenario: Writing an empty entry from the editor
Given we use the config "editor.yaml"
When we open the editor and enter ""
Then we should see the message "[Nothing saved to file]"
Scenario: Writing an empty entry from the command line
Given we use the config "basic.yaml"
When we run "jrnl ''"
Then we should get no error
And the unstripped output should be
"""
"""
Scenario: Filtering for dates
Given we use the config "basic.yaml"
When we run "jrnl -on 2013-06-10 --short"

View file

@ -211,6 +211,15 @@ def check_output(context, text=None):
for line_text, line_out in zip(text, out):
assert line_text.strip() == line_out.strip(), [line_text.strip(), line_out.strip()]
@then('the unstripped output should be')
@then('the unstripped output should be "{text}"')
def check_output(context, text=None):
text = (text or context.text).splitlines()
out = context.stdout_capture.getvalue().splitlines()
assert len(text) == len(out), "Output has {} lines (expected: {})".format(len(out), len(text))
for line_text, line_out in zip(text, out):
assert line_text == line_out, [line_text, line_out]
@then('the output should contain "{text}" in the local time')
def check_output_time_inline(context, text):