Skip to content

Commit 9d1b52f

Browse files
committed
Add a test for #3, to check we fall back to correctly
1 parent 5e1d506 commit 9d1b52f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/test-open.bats

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ load 'helpers'
66

77
function open() { echo "Opening $*"; }
88
export -f open
9+
910
function edit() { echo "Editing $*"; }
1011
export -f edit
1112
export EDITOR="edit"
@@ -80,4 +81,16 @@ notes="./notes"
8081

8182
assert_success
8283
assert_output "Editing $NOTES_DIRECTORY/note.md"
84+
}
85+
86+
@test "Uses 'editor' if $EDITOR is not available" {
87+
unset EDITOR
88+
# Simulate a `editor` symlink (as in Debian/Ubuntu/etc)
89+
function editor() { echo "Editor bin, editing $*"; }
90+
export -f editor
91+
92+
run bash -c "$notes open note.md"
93+
94+
assert_success
95+
assert_output "Editor bin, editing $NOTES_DIRECTORY/note.md"
8396
}

0 commit comments

Comments
 (0)