Skip to content

Commit 6f9247c

Browse files
committed
Add an extra EDITOR test to confirm the combinations work correctly
1 parent c364765 commit 6f9247c

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

test/test-open.bats

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ notes="./notes"
2929
assert_output "Opening $HOME/notes"
3030
}
3131

32-
@test "Exits if \$EDITOR isn't set and 'editor' doesn't exist" {
33-
unset EDITOR
34-
function type() { [ $1 != "editor" ]; } # Pretend editor doesn't exist.
35-
export -f type
36-
37-
run $notes open test
38-
39-
assert_failure
40-
assert_output "Please set \$EDITOR to edit notes"
41-
}
42-
4332
@test "Opens the configured notes directory if set" {
4433
run $notes open
4534

@@ -104,4 +93,26 @@ notes="./notes"
10493

10594
assert_success
10695
assert_output "Editor bin, editing $NOTES_DIRECTORY/note.md"
96+
}
97+
98+
@test "Uses \$EDITOR over 'editor' if both are available" {
99+
# Simulate a `editor` symlink (as in Debian/Ubuntu/etc)
100+
function editor() { echo "Editor bin, editing $*"; }
101+
export -f editor
102+
103+
run bash -c "$notes open note.md"
104+
105+
assert_success
106+
assert_output "Editing $NOTES_DIRECTORY/note.md"
107+
}
108+
109+
@test "Exits if \$EDITOR isn't set and 'editor' doesn't exist" {
110+
unset EDITOR
111+
function type() { [ $1 != "editor" ]; } # Pretend editor doesn't exist.
112+
export -f type
113+
114+
run $notes open test
115+
116+
assert_failure
117+
assert_output "Please set \$EDITOR to edit notes"
107118
}

0 commit comments

Comments
 (0)