Working
This commit is contained in:
39
test.sh
Executable file
39
test.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#! /bin/bash
|
||||
|
||||
SCRIPT_DIR=$(dirname $0)
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
|
||||
# test jq is installed
|
||||
if ! command -v jq &> /dev/null; then
|
||||
echo "jq could not be found"
|
||||
echo "sudo apt-get install jq"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# read ~/.config/simple_object_storage/config.json
|
||||
CONFIG_PATH="${HOME}/.config/simple_object_storage/config.json"
|
||||
if [ ! -f "${CONFIG_PATH}" ]; then
|
||||
echo "config file not found at ${CONFIG_PATH}"
|
||||
exit 1
|
||||
fi
|
||||
CONFIG=$(cat "${CONFIG_PATH}")
|
||||
|
||||
# get the host and port from the config
|
||||
HOST=$(echo $CONFIG | jq -r '.host')
|
||||
PORT=$(echo $CONFIG | jq -r '.port')
|
||||
|
||||
# extract the first write token from the config
|
||||
WRITE_TOKEN=$(echo $CONFIG | jq -r '.write_tokens[0]')
|
||||
|
||||
BASE_URL="http://${HOST}:${PORT}"
|
||||
|
||||
BASE_TAG="autotest"
|
||||
|
||||
# test every action in the README.md file, leaving the system in the same state it was found
|
||||
# and print the output of each action
|
||||
|
||||
# upload this script as an object
|
||||
echo "uploading ${SCRIPT_DIR}/${SCRIPT_NAME} to ${BASE_TAG}:test1"
|
||||
OBJECT_HASH=$(curl "${BASE_URL}/upload?token=${WRITE_TOKEN}&labeltag=${BASE_TAG}:test1&filename=${SCRIPT_NAME}" -T ${SCRIPT_DIR}/${SCRIPT_NAME} | jq -r '.hash')
|
||||
echo "received hash ${OBJECT_HASH}"
|
||||
|
Reference in New Issue
Block a user