mirror of
https://github.com/jimeh/dotify.git
synced 2026-02-19 10:06:39 +00:00
<source> was an optional argument, and the second out of three passed, meaning when only two arguments were given, the action functions would have to know to use the second argument as <target>, instead of the the third. Now the second argument is always <target>, and the <source> argument is always the third, if given.
38 lines
1.0 KiB
Bash
Executable File
38 lines
1.0 KiB
Bash
Executable File
#! /usr/bin/env bash
|
|
source "../test-helper.sh"
|
|
source "../../src/lib/dotify-action.sh"
|
|
|
|
#
|
|
# dotify-action() tests
|
|
#
|
|
|
|
# Set required environment variables.
|
|
DOTIFY_RUN_MODE="install"
|
|
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: install .ackrc ackrc"
|
|
|
|
# Given a specific action without a <source>.
|
|
assert "dotify-action link .ackrc" "link stub: install .ackrc"
|
|
|
|
# Given "default" action, it uses configured default action.
|
|
assert "dotify-action default ackrc .ackrc" "link stub: install .ackrc ackrc"
|
|
|
|
# Given "default" action without a <source>, it uses configured default
|
|
# action.
|
|
assert "dotify-action default .ackrc" "link stub: install .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()"
|