Last active
February 15, 2017 16:24
-
-
Save achilleas-k/dc5c0ba6e33056a636782e75ce331d23 to your computer and use it in GitHub Desktop.
Shell script for testing the command line interface to GIN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
set -e | |
user=achilleas | |
reponame=test-repo-${RANDOM} | |
dirone=/tmp/gin-test-repos/directory-one | |
dirtwo=/tmp/gin-test-repos/directory-two | |
cdprint() { | |
echo "--> cd ${*}" | |
cd $* | |
echo "--> CWD: $(pwd)" | |
} | |
checkdupes() { | |
expected=$1 | |
dupes=$(fdupes -n1A -r ${dirone}/${reponame} ${dirtwo}/${reponame}) | |
ndupes=$(wc -l <<< ${dupes}) | |
if [ $ndupes -ne ${expected} ] | |
then | |
echo "--> Found ${ndupes}. Was expecting ${expected}" | |
echo $dupes | |
exit 1 | |
fi | |
echo "--> Correctly found ${expected} duplicate files" | |
} | |
echo "--> Logging out" | |
gin logout || true | |
echo "--> Getting info of user [${user}] without login" | |
gin info ${user} | |
echo "--> Trying some commands that should fail" | |
gin keys || echo "--> Failed successfully" | |
gin keys --add /dev/null || echo "--> Failed successfully" | |
gin create "foo" || echo "--> Failed successfully" | |
echo "--> Logging in (prompting for password)" | |
gin login ${user} | |
echo "--> Getting info of user [${user}] after login" | |
gin info ${user} | |
echo "--> Creating and downloading new repository" | |
mkdir -p ${dirone} | |
cdprint ${dirone} | |
gin create ${reponame} | |
gin get ${user}/${reponame} | |
cdprint ${reponame} | |
echo "--> Adding some large files (should be annexed)" | |
dd if=/dev/urandom of=test-file-${RANDOM}.rnd bs=5M count=6 | |
dd if=/dev/urandom of=test-file-${RANDOM}.rnd bs=5M count=6 | |
echo "--> Adding a small README (should be checked into git proper)" | |
echo "--> This is the readme file for test repository ${reponame}" > README.txt | |
echo "--> Performing upload" | |
gin upload | |
echo "--> Downloading repository to secondary directory" | |
mkdir -p ${dirtwo} | |
cdprint ${dirtwo} | |
gin get ${user}/${reponame} | |
cdprint ${reponame} | |
echo "--> Checking if downloaded files are the same as the uploaded ones" | |
checkdupes 3 | |
echo "--> Creating additional file in secondary directory" | |
cdprint ${dirtwo}/${reponame} | |
dd if=/dev/urandom of=new-test-file-${RANDOM}.rnd bs=1M count=12 | |
echo "--> Performing upload" | |
gin upload | |
echo "--> Checking duplicates before downloading to primary" | |
checkdupes 3 | |
echo "--> Downloading new file to primary directory" | |
cdprint ${dirone}/${reponame} | |
gin download | |
echo "--> Checking duplicates including new file" | |
checkdupes 4 | |
echo "--> DONE! Everything *seems* to be OK <--" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment