mirror of
https://github.com/deadc0de6/catcli
synced 2024-11-11 13:11:00 +00:00
add tests-ng
This commit is contained in:
parent
bd5d504997
commit
9b77b2a360
72
tests-ng/update.sh
Executable file
72
tests-ng/update.sh
Executable file
@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
# author: deadc0de6 (https://github.com/deadc0de6)
|
||||
# Copyright (c) 2021, deadc0de6
|
||||
|
||||
cur=$(dirname "$(readlink -f "${0}")")
|
||||
cwd=`pwd`
|
||||
|
||||
# pivot
|
||||
cd ${cur}/../
|
||||
python3 -m catcli.catcli --version
|
||||
|
||||
##########################################################
|
||||
# the test
|
||||
##########################################################
|
||||
|
||||
# create temp dirs
|
||||
tmpd=`mktemp -d`
|
||||
tmpu=`mktemp -d -p ${cur}`
|
||||
|
||||
# setup cleaning
|
||||
clean() {
|
||||
# clean
|
||||
rm -rf ${tmpd} ${tmpu}
|
||||
}
|
||||
trap clean EXIT
|
||||
|
||||
catalog="${tmpd}/catalog"
|
||||
|
||||
mkdir -p ${tmpd}/dir
|
||||
echo "abc" > ${tmpd}/dir/a
|
||||
|
||||
# index
|
||||
python3 -m catcli.catcli -B index --catalog=${catalog} dir ${tmpd}/dir
|
||||
python3 -m catcli.catcli -B ls --catalog=${catalog} dir
|
||||
|
||||
# get attributes
|
||||
freeb=`python3 -m catcli.catcli -B ls --catalog=${catalog} dir | grep free: | sed 's/^.*,free:\([^ ]*\).*$/\1/g'`
|
||||
dub=`python3 -m catcli.catcli -B ls --catalog=${catalog} dir | grep du: | sed 's/^.*,du:\([^ ]*\).*$/\1/g'`
|
||||
dateb=`python3 -m catcli.catcli -B ls --catalog=${catalog} dir | grep date: | sed 's/^.*,date: \(.*\)$/\1/g'`
|
||||
echo "before: free:${freeb} | du:${dub} | date:${dateb}"
|
||||
|
||||
# change content
|
||||
echo "abc" >> ${tmpd}/dir/a
|
||||
echo "abc" > ${tmpd}/dir/b
|
||||
|
||||
# move dir
|
||||
cp -r ${tmpd}/dir ${tmpu}/
|
||||
|
||||
# sleep to force date change
|
||||
sleep 1
|
||||
|
||||
# update
|
||||
python3 -m catcli.catcli -B update -f --catalog=${catalog} dir ${tmpu}/dir
|
||||
python3 -m catcli.catcli -B ls --catalog=${catalog} dir
|
||||
|
||||
# get new attributes
|
||||
freea=`python3 -m catcli.catcli -B ls --catalog=${catalog} dir | grep free: | sed 's/^.*,free:\([^ ]*\).*$/\1/g'`
|
||||
dua=`python3 -m catcli.catcli -B ls --catalog=${catalog} dir | grep du: | sed 's/^.*,du:\([^ ]*\).*$/\1/g'`
|
||||
datea=`python3 -m catcli.catcli -B ls --catalog=${catalog} dir | grep date: | sed 's/^.*,date: \(.*\)$/\1/g'`
|
||||
echo "after: free:${freea} | du:${dua} | date:${datea}"
|
||||
|
||||
# test they are all different
|
||||
[ "${freeb}" = "${freea}" ] && echo "free didn't change!" && exit 1
|
||||
[ "${dub}" = "${dua}" ] && echo "du didn't change!" && exit 1
|
||||
[ "${dateb}" = "${datea}" ] && echo "date didn't change!" && exit 1
|
||||
|
||||
# pivot back
|
||||
cd ${cwd}
|
||||
|
||||
# the end
|
||||
echo "test \"`basename $0`\" success"
|
||||
exit 0
|
7
tests.sh
7
tests.sh
@ -2,6 +2,8 @@
|
||||
# author: deadc0de6 (https://github.com/deadc0de6)
|
||||
# Copyright (c) 2017, deadc0de6
|
||||
|
||||
cur=$(dirname "$(readlink -f "${0}")")
|
||||
|
||||
# stop on first error
|
||||
set -ev
|
||||
|
||||
@ -13,3 +15,8 @@ pyflakes tests/
|
||||
|
||||
PYTHONPATH=catcli python3 -m nose -s --with-coverage --cover-package=catcli
|
||||
#PYTHONPATH=catcli python3 -m nose -s
|
||||
|
||||
for t in ${cur}/tests-ng/*; do
|
||||
echo "running test \"`basename ${t}`\""
|
||||
${t}
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user