This commit is contained in:
Your Name
2025-05-03 15:08:25 +12:00
parent 7df5c75539
commit c456fb4225
6 changed files with 237 additions and 25 deletions

39
test.sh Executable file
View 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}"