Skip to content

Commit

Permalink
Add a test for pimterry#3, to check we fall back to correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
pimterry committed Dec 2, 2016
1 parent 5e1d506 commit 9d1b52f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/test-open.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ load 'helpers'

function open() { echo "Opening $*"; }
export -f open

function edit() { echo "Editing $*"; }
export -f edit
export EDITOR="edit"
Expand Down Expand Up @@ -80,4 +81,16 @@ notes="./notes"

assert_success
assert_output "Editing $NOTES_DIRECTORY/note.md"
}

@test "Uses 'editor' if $EDITOR is not available" {
unset EDITOR
# Simulate a `editor` symlink (as in Debian/Ubuntu/etc)
function editor() { echo "Editor bin, editing $*"; }
export -f editor

run bash -c "$notes open note.md"

assert_success
assert_output "Editor bin, editing $NOTES_DIRECTORY/note.md"
}

0 comments on commit 9d1b52f

Please sign in to comment.