2023-04-04 13:36:51 +00:00
|
|
|
#
|
|
|
|
# Pipeline uni tests using BATS framework.
|
|
|
|
#
|
|
|
|
|
|
|
|
bats_require_minimum_version 1.5.0
|
|
|
|
|
|
|
|
setup() {
|
2023-05-10 22:56:10 +00:00
|
|
|
# shellcheck source=./tests/tests.conf
|
2023-04-04 13:36:51 +00:00
|
|
|
source "${PWD}/tests/tests.conf"
|
|
|
|
make build >/dev/null
|
|
|
|
DESTDIR="${temp}" make install >/dev/null
|
|
|
|
install --no-target-directory \
|
|
|
|
"${PWD}/tests/tests.conf" \
|
|
|
|
"${temp}${sysconf_dir}/${name}/${name}.conf"
|
2023-05-10 22:56:10 +00:00
|
|
|
# shellcheck source=./conf/errors.conf.sample
|
2023-04-04 13:36:51 +00:00
|
|
|
source "${errs_file}"
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
rm --recursive --force "${temp}"
|
|
|
|
make clean >/dev/null
|
|
|
|
}
|
|
|
|
|
2023-05-10 22:56:10 +00:00
|
|
|
run_with_bad_arguments() { #@test
|
2023-04-04 13:36:51 +00:00
|
|
|
run -1 "${pipeline_bin}"
|
|
|
|
run -1 "${pipeline_bin}" bad_pipeline
|
|
|
|
|
|
|
|
run -1 "${pipeline_bin}" newcommit
|
|
|
|
run -1 "${pipeline_bin}" -H hash newcommit
|
|
|
|
run -1 "${pipeline_bin}" -n name newcommit
|
|
|
|
|
|
|
|
run -1 "${pipeline_bin}" newtag
|
|
|
|
run -1 "${pipeline_bin}" -H hash newtag
|
|
|
|
run -1 "${pipeline_bin}" -n name newtag
|
|
|
|
run -1 "${pipeline_bin}" -T tag newtag
|
|
|
|
run -1 "${pipeline_bin}" -H hash -n name newtag
|
|
|
|
run -1 "${pipeline_bin}" -H hash -T tag newtag
|
|
|
|
run -1 "${pipeline_bin}" -n name -T tag newtag
|
|
|
|
|
|
|
|
run -1 "${pipeline_bin}" -c /path/to/nowhere -H hash -n name newcommit
|
|
|
|
run -1 "${pipeline_bin}" -e /path/to/nowhere -H hash -n name newcommit
|
|
|
|
}
|
|
|
|
|
2023-05-10 22:56:10 +00:00
|
|
|
run_without_runner_sock() { #@test
|
2023-04-04 13:36:51 +00:00
|
|
|
run "${pipeline_bin}" --conf="${conf_file}" --errs="${errs_file}" \
|
|
|
|
--test --hash hash --name name newcommit
|
2023-05-10 22:56:10 +00:00
|
|
|
echo "status: got ${status:?}, expected ${err_runner_sock_not_exist}"
|
2023-04-04 13:36:51 +00:00
|
|
|
[ "${status}" -eq "${err_runner_sock_not_exist}" ]
|
|
|
|
}
|
|
|
|
|
2023-05-10 22:56:10 +00:00
|
|
|
run_newcommit_ok() { #@test
|
2023-04-04 13:36:51 +00:00
|
|
|
ncat --listen --unixsock "${runner_sock}" &
|
|
|
|
"${pipeline_bin}" --conf="${conf_file}" --errs="${errs_file}" \
|
|
|
|
--test --hash hash --name name newcommit
|
|
|
|
echo "done" | ncat --unixsock "${runner_sock}"
|
|
|
|
}
|
|
|
|
|
2023-05-10 22:56:10 +00:00
|
|
|
run_newtag_ok() { #@test
|
2023-04-04 13:36:51 +00:00
|
|
|
ncat --listen --unixsock "${runner_sock}" &
|
|
|
|
"${pipeline_bin}" --conf="${conf_file}" --errs="${errs_file}" \
|
|
|
|
--test --hash hash --name name --tag tag newtag
|
|
|
|
echo "done" | ncat --unixsock "${runner_sock}"
|
|
|
|
}
|