1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2025-06-13 13:03:58 +00:00
TheLocehiliosan_yadm/test/115_accept_introspect.bats
Thomas Luzat 727e656ceb
Implement additional alternate file directory
This introduced a proof of concept implementation for an additional
directory which contains alternate files to be linked into ~. The
default path is ~/.yadm/alt. A file ~/.yadm/alt/foo## would be linked
to ~/foo.

The directory is optional and can be overriden using the configuration
option yadm.alt, which is a path relative to ~ (e.g. .yadm/my-alt).
The command-line option --yadm-alt allows overriding the path with an
absolute path (e.g. ~/.yadm/my-alt).

Caveats: This feature is hardly tested and does not come with any tests
or documentation. It will break if yadm.alt or --yadm-alt are not
normalized paths, but may break in many other cases, too (e.g. wildcards
in path names, esoteric symlink setups or just because of bugs).
2017-10-09 15:40:39 +02:00

100 lines
2.2 KiB
Bash

load common
load_fixtures
status=;output=; #; populated by bats run()
function count_introspect() {
local category="$1"
local expected_status="$2"
local expected_words="$3"
local expected_regex="$4"
run "${T_YADM_Y[@]}" introspect "$category"
local output_words
output_words=$(wc -w <<< "$output")
if [ "$status" -ne "$expected_status" ]; then
echo "ERROR: Unexpected exit code (expected $expected_status, got $status)"
return 1;
fi
if [ "$output_words" -ne "$expected_words" ]; then
echo "ERROR: Unexpected number of output words (expected $expected_words, got $output_words)"
return 1;
fi
if [ -n "$expected_regex" ]; then
if [[ ! "$output" =~ $expected_regex ]]; then
echo "OUTPUT:$output"
echo "ERROR: Output does not match regex: $expected_regex"
return 1;
fi
fi
}
@test "Command 'introspect' (no category)" {
echo "
When 'introspect' command is provided,
And no category is provided
Produce no output
Exit with 0
"
count_introspect "" 0 0
}
@test "Command 'introspect' (invalid category)" {
echo "
When 'introspect' command is provided,
And an invalid category is provided
Produce no output
Exit with 0
"
count_introspect "invalid_cat" 0 0
}
@test "Command 'introspect' (commands)" {
echo "
When 'introspect' command is provided,
And category 'commands' is provided
Produce command list
Exit with 0
"
count_introspect "commands" 0 15 'version'
}
@test "Command 'introspect' (configs)" {
echo "
When 'introspect' command is provided,
And category 'configs' is provided
Produce switch list
Exit with 0
"
count_introspect "configs" 0 14 'yadm\.auto-alt'
}
@test "Command 'introspect' (repo)" {
echo "
When 'introspect' command is provided,
And category 'repo' is provided
Output repo
Exit with 0
"
count_introspect "repo" 0 1 "$T_DIR_REPO"
}
@test "Command 'introspect' (switches)" {
echo "
When 'introspect' command is provided,
And category 'switches' is provided
Produce switch list
Exit with 0
"
count_introspect "switches" 0 8 '--yadm-dir'
}