-
-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exit jrnl if no text entered into editor #744
Conversation
I see two ways to test this (and other related functionality):
|
This solution makes sense to me. I'm thinking this is somewhat along the lines of how I'll implement it, but I'm a little shaky on the details. (The following is left as notes for myself when I have time to finish thinking about this.) The feature test may look like this: Scenario: Writing an empty entry from the editor
Given we use the config "basic.yaml"
When we open the editor and exit
Then there should be no output Where Note that this would mean the test will require no output, when in reality, the output would be Note: I'm not sure that the test I've written actually does anything at the moment... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be a bigger fan of patching the concrete subprocess call. Generally you should avoid patching your own code, especially if it has side-effects (like the printed output). I mentioned it earlier because it was easier but I didn't consider it would change the output.
Yep, agreed. Will fix when I've got some time. |
Co-Authored-By: pspeter <peter.schmidb@gmail.com>
Co-Authored-By: pspeter <peter.schmidb@gmail.com>
There we go :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not super necessary I guess but after moving the sys.exit() down, you could also add a second test that is exactly the same as this one but uses the basic.yaml
and When we run jrnl and enter ""
(and add @when('we run "{command}" and enter ""')
to the corresponding step function...) to also test the early exit when no editor is used.
But otherwise it looks good now 👍
I honestly don't think that's necessary. Who's going to be running |
Line 202 in 4318da5
But this can also be exited without writing anything, leaving you with an empty string again. They would still call |
Oh, so this would happen if someone tried to |
This test breaks for some unknown reason. Will take a look at it again when I have time. I have to do some other work... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try this
Co-Authored-By: pspeter <peter.schmidb@gmail.com>
@wren: This PR is also ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Fix #589
Pretty self-explanatory.
I was trying to think of a creative way to test this but I don't think we can automate exiting the editor cleanly (and judging by the lack of tests for anything relating to an editor, I think everyone else has come to the same conclusion that I did.)Checklist