Commit 0cb9b984 authored by Baptiste Daroussin's avatar Baptiste Daroussin
Browse files

triggers: add tests for deferred triggers

parent 1e888a83
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
. $(atf_get_srcdir)/test_environment.sh . $(atf_get_srcdir)/test_environment.sh
tests_init \ tests_init \
cleanup_lua cleanup_lua \
deferred
cleanup_lua_body() { cleanup_lua_body() {
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/" atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
...@@ -31,3 +32,34 @@ EOF ...@@ -31,3 +32,34 @@ EOF
atf_check pkg -o REPOS_DIR=/dev/null -o PKG_TRIGGERS_DIR="${TMPDIR}/trigger_dir" install -qfy ${TMPDIR}/test-1.pkg atf_check pkg -o REPOS_DIR=/dev/null -o PKG_TRIGGERS_DIR="${TMPDIR}/trigger_dir" install -qfy ${TMPDIR}/test-1.pkg
atf_check -o inline:"Cleaning up\n" pkg -o REPOS_DIR=/dev/null -o PKG_TRIGGERS_DIR="${TMPDIR}/trigger_dir" delete -qy test atf_check -o inline:"Cleaning up\n" pkg -o REPOS_DIR=/dev/null -o PKG_TRIGGERS_DIR="${TMPDIR}/trigger_dir" delete -qy test
} }
deferred_body() {
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "/"
mkdir trigger_dir/
cat << EOF >> trigger_dir/trigger.ucl
path_glob: [ "/*" ]
trigger: {
type: lua
script: <<EOS
print "deferred"
EOS
}
EOF
echo trigger_dir/trigger.ucl > plist
atf_check pkg create -M test.ucl -p plist -r .
mkdir target
unset PKG_TRIGGERS_DIR
unset PKG_DBDIR
atf_check pkg -o REPOS_DIR=/dev/null -o PKG_TRIGGERS_DIR="/trigger_dir" -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
OUTPUT='--sandbox
--begin args
-- /trigger_dir
--end args
--
print "deferred"
'
atf_check -o inline:"${OUTPUT}" cat ${TMPDIR}/target/var/db/pkg/triggers/*
atf_check -o inline:"deferred\n" pkg -o PKG_DBDIR=${TMPDIR}/target/var/db/pkg triggers
# test the deferred trigger has been removed
atf_check ls ${TMPDIR}/target/var/db/pkg/triggers
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment