2017-08-03 15:40:43 +02:00
|
|
|
#!/bin/env bats
|
|
|
|
|
|
|
|
@test "Testing transfer tool" {
|
|
|
|
echo transfer
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Check for latest version of bash-snippets on update" {
|
|
|
|
if [[ "$(uname)" == "Linux" ]];then
|
|
|
|
run transfer update
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "Bash-Snippets is already the latest version" ]
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "The -h option should print usage" {
|
|
|
|
run transfer -h
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "${lines[0]}" = "Transfer" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Testing file upload" {
|
2017-08-04 03:03:15 +02:00
|
|
|
touch $HOME/testFile.txt
|
|
|
|
echo -n "This is some example content." > $HOME/testFile.txt
|
2017-08-06 00:13:47 +02:00
|
|
|
run transfer $HOME/testFile.txt
|
|
|
|
transferResponse=$(transfer $HOME/testFile.txt)
|
2017-08-04 03:03:15 +02:00
|
|
|
rm -f $HOME/testFile.txt
|
2017-08-03 15:40:43 +02:00
|
|
|
transferCommand=$( echo $transferResponse | cut -d $'\n' -f 3 | sed s/"Transfer Download Command:"//g | sed s:"desiredOutputDirectory":"$HOME":g | sed s:"^ "::g)
|
|
|
|
transferStatus=$( echo $transferResponse | grep -Eo "Success!")
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$transferStatus" = "Success!" ] ## this works for darwin but the test wont
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-04 03:03:15 +02:00
|
|
|
@test "Testing file upload & download" {
|
|
|
|
touch $HOME/testFile.txt
|
|
|
|
echo -n "This is some example content." > $HOME/testFile.txt
|
2017-08-06 00:13:47 +02:00
|
|
|
transferResponse=$(transfer $HOME/testFile.txt)
|
2017-08-04 03:03:15 +02:00
|
|
|
#transferCommand=$( echo $transferResponse | cut -d $'\n' -f 3 | sed s/"Transfer Download Command:"//g | sed s:"desiredOutputDirectory":"$HOME":g | sed s:"^ "::g)
|
|
|
|
id=$(echo $transferResponse | cut -d "/" -f 4)
|
|
|
|
transferStatus=$( echo $transferResponse | grep -Eo "Success!")
|
|
|
|
[ "$transferStatus" = "Success!" ]
|
|
|
|
rm -f $HOME/testFile.txt
|
|
|
|
if [ -f $HOME/testFile.txt ];then exit 1;fi
|
|
|
|
run transfer -d $HOME $id testFile.txt
|
|
|
|
if [ ! -f $HOME/testFile.txt ];then exit 1;fi
|
|
|
|
contents=$(cat $HOME/testFile.txt)
|
|
|
|
if [ $contents != "This is some example content." ];then exit 1; fi
|
|
|
|
rm -f $HOME/testFile.txt
|
|
|
|
transferResponse=$(transfer -d $HOME $id testFile.txt)
|
|
|
|
transferStatus=$( echo $transferResponse | grep -Eo "Success!")
|
|
|
|
[ "$transferStatus" = "Success!" ]
|
|
|
|
rm -f $HOME/testFile.txt
|
|
|
|
}
|
2017-08-03 15:40:43 +02:00
|
|
|
|
|
|
|
@test "Get the tools version with -v" {
|
|
|
|
run transfer -v
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
result=$( echo $(transfer -v) | grep -Eo "Version")
|
|
|
|
[ "$result" = "Version" ]
|
|
|
|
}
|