@ -129,3 +129,74 @@ setup() {
return 1
fi
}
@test "Command 'config' (local read)" {
echo "
When 'config' command is provided,
and an attribute is provided
and the attribute is configured
and the attribute is local.*
Fetch the value from the repo config
Report the requested value
Exit with 0
"
#; write local attributes
build_repo
for loption in class os host user; do
GIT_DIR="$T_DIR_REPO" git config "local.$loption" "custom_$loption"
done
#; run config
for loption in class os host user; do
run "${T_YADM_Y[@]}" config "local.$loption"
#; validate status and output
[ $status -eq 0 ]
if [ "$output" != "custom_$loption" ]; then
echo "ERROR: Incorrect value returned. Expected 'custom_$loption', got '$output'"
return 1
fi
done
}
@test "Command 'config' (local write)" {
echo "
When 'config' command is provided,
and an attribute is provided
and a value is provided
and the attribute is local.*
Report no output
Write the value to the repo config
Exit with 0
"
build_repo
local expected
local linecount
expected="[local]\n"
linecount=1
for loption in class os host user; do
#; update expected
expected="$expected\t$loption = custom_$loption\n"
((linecount+=1))
#; write local attributes
run "${T_YADM_Y[@]}" config "local.$loption" "custom_$loption"
#; validate status and output
[ $status -eq 0 ]
[ "$output" = "" ]
done
#; validate data
local config
config=$(tail "-$linecount" "$T_DIR_REPO/config")
expected=$(echo -ne "$expected")
if [ "$config" != "$expected" ]; then
echo "ERROR: Config does not match expected"
echo -e "$config"
echo -e "EXPECTED:\n$expected"
return 1
fi
}