diff options
author | Michał Górny <mgorny@gentoo.org> | 2021-04-13 15:28:57 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2021-04-13 15:29:05 +0200 |
commit | c7717708c0eb326a6fffafb90f08f4ea07616463 (patch) | |
tree | b1a0dcf0e1c6fd92df6afd5f6ff356ca0b40cc9c /dev-python/mongoengine | |
parent | app-misc/tmux: Version bump (v3.2) (diff) | |
download | gentoo-c7717708c0eb326a6fffafb90f08f4ea07616463.tar.gz gentoo-c7717708c0eb326a6fffafb90f08f4ea07616463.tar.bz2 gentoo-c7717708c0eb326a6fffafb90f08f4ea07616463.zip |
dev-python/mongoengine: Run local mongodb instance for testing
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/mongoengine')
-rw-r--r-- | dev-python/mongoengine/mongoengine-0.23.0.ebuild | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/dev-python/mongoengine/mongoengine-0.23.0.ebuild b/dev-python/mongoengine/mongoengine-0.23.0.ebuild index d6ca245f7e8e..70ccf79efec0 100644 --- a/dev-python/mongoengine/mongoengine-0.23.0.ebuild +++ b/dev-python/mongoengine/mongoengine-0.23.0.ebuild @@ -13,8 +13,6 @@ SRC_URI="https://github.com/MongoEngine/${PN}/archive/v${PV}.tar.gz -> ${P}.tar. LICENSE="BSD" SLOT="0" KEYWORDS="~amd64 ~x86" -# TODO: make it run a local database server -RESTRICT="test" RDEPEND="dev-python/blinker[${PYTHON_USEDEP}] dev-python/pillow[${PYTHON_USEDEP}] @@ -42,3 +40,38 @@ src_prepare() { distutils-r1_src_prepare } + +python_test() { + local dbpath=${TMPDIR}/mongo.db + local logpath=${TMPDIR}/mongod.log + + mkdir -p "${dbpath}" || die + ebegin "Trying to start mongod on port ${DB_PORT}" + + LC_ALL=C \ + mongod --dbpath "${dbpath}" --nojournal \ + --bind_ip 127.0.0.1 --port 27017 \ + --unixSocketPrefix "${TMPDIR}" \ + --logpath "${logpath}" --fork || die + sleep 2 + + # Now we need to check if the server actually started... + if [[ -S "${TMPDIR}"/mongodb-27017.sock ]]; then + # yay! + eend 0 + else + eend 1 + eerror "Unable to start mongod for tests. See the server log:" + eerror " ${logpath}" + die "Unable to start mongod for tests." + fi + + local failed + nonfatal epytest || failed=1 + + mongod --dbpath "${dbpath}" --shutdown || die + + [[ ${failed} ]] && die "Tests fail with ${EPYTHON}" + + rm -rf "${dbpath}" || die +} |