Make dotify-action error out when given invalid actions

This commit is contained in:
2013-10-21 01:30:42 +01:00
parent 27f163e9fe
commit fad6369ba7
2 changed files with 35 additions and 0 deletions

29
test/lib/dotify-action-test.sh Executable file
View 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()"