mirror of
https://github.com/jimeh/dotify.git
synced 2026-02-19 10:06:39 +00:00
Make dotify-action error out when given invalid actions
This commit is contained in:
29
test/lib/dotify-action-test.sh
Executable file
29
test/lib/dotify-action-test.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#! /usr/bin/env bash
|
||||
source "../test-helper.sh"
|
||||
source "../../src/lib/dotify-action.sh"
|
||||
|
||||
#
|
||||
# dotify-action() tests
|
||||
#
|
||||
|
||||
# Set required option ENV
|
||||
DOTIFY_OPT_DEFAULT_ACTION="link"
|
||||
|
||||
# Simple mock for link action.
|
||||
dotify-action-link() {
|
||||
echo "link stub: $@"
|
||||
}
|
||||
|
||||
|
||||
# Given a specific action.
|
||||
assert "dotify-action link ackrc .ackrc" "link stub: ackrc .ackrc"
|
||||
|
||||
# Given "default" action, it uses configured default action.
|
||||
assert "dotify-action default ackrc .ackrc" "link stub: ackrc .ackrc"
|
||||
|
||||
# Given a invalid action.
|
||||
assert_raises "dotify-action foo ackrc .ackrc" 1
|
||||
assert "dotify-action foo ackrc .ackrc" ""
|
||||
assert "dotify-action foo ackrc .ackrc 2>&1" "ERROR: \"foo\" is not a valid action."
|
||||
|
||||
assert_end "dotify-action()"
|
||||
Reference in New Issue
Block a user