forked from agorise/c-ipfs
more test scripts
This commit is contained in:
parent
81e103f1e0
commit
3418ee5435
3 changed files with 66 additions and 10 deletions
|
@ -4,17 +4,8 @@ source ./test_helpers.sh
|
|||
|
||||
IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
||||
|
||||
function check_failure() {
|
||||
FUNC=$1;
|
||||
RESULT=$2;
|
||||
if [ $RESULT -eq 0 ]; then
|
||||
echo "";
|
||||
else
|
||||
echo "Failure in $FUNC. The return value was $RESULT";
|
||||
fi
|
||||
}
|
||||
|
||||
function pre {
|
||||
post
|
||||
eval "$IPFS" init;
|
||||
check_failure "pre" $?
|
||||
}
|
||||
|
@ -27,7 +18,10 @@ function post {
|
|||
function body {
|
||||
create_hello_world;
|
||||
eval "$IPFS" add hello.txt
|
||||
check_failure "add hello.txt" $?
|
||||
|
||||
eval "$IPFS" cat QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
||||
check_failure "cat hello.txt" $?
|
||||
}
|
||||
|
||||
|
||||
|
|
39
test/scripts/test_3.sh
Executable file
39
test/scripts/test_3.sh
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
####
|
||||
# Attempt to start a deamon and have an api client do a object get
|
||||
#
|
||||
####
|
||||
|
||||
source ./test_helpers.sh
|
||||
|
||||
IPFS="../../main/ipfs --config /tmp/ipfs_1"
|
||||
|
||||
function pre {
|
||||
post
|
||||
eval "$IPFS" init;
|
||||
check_failure "pre" $?
|
||||
}
|
||||
|
||||
function post {
|
||||
rm -Rf /tmp/ipfs_1;
|
||||
rm hello.txt;
|
||||
}
|
||||
|
||||
function body {
|
||||
create_hello_world;
|
||||
eval "$IPFS" add hello.txt
|
||||
check_failure "add hello.txt" $?
|
||||
|
||||
#start the daemon
|
||||
eval "../../main/ipfs --config /tmp/ipfs_1 daemon &"
|
||||
daemon_id=$!
|
||||
sleep 5
|
||||
|
||||
eval "$IPFS" cat QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH
|
||||
check_failure "cat hello.txt" $?
|
||||
|
||||
kill -9 $daemon_id
|
||||
}
|
||||
|
||||
|
|
@ -1,3 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
#####
|
||||
# Functions to help with test scripts
|
||||
#####
|
||||
|
||||
####
|
||||
# Create a text file "hello.txt" that contains "Hello, World!"
|
||||
####
|
||||
function create_hello_world {
|
||||
echo 'Hello, World!' > hello.txt
|
||||
}
|
||||
|
||||
####
|
||||
# Checks the return code and displays message if return code is not 0
|
||||
# Param $1 name of function
|
||||
# Param $2 return code
|
||||
####
|
||||
function check_failure() {
|
||||
FUNC=$1;
|
||||
RESULT=$2;
|
||||
if [ $RESULT -ne 0 ]; then
|
||||
echo "***Failure*** in $FUNC. The return value was $RESULT";
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue