Bug fixing

This commit is contained in:
Your Name
2025-05-25 11:58:46 +12:00
parent b0e8f1f703
commit dbb9adf890

36
test.sh
View File

@@ -144,15 +144,45 @@ UPLOAD_RESPONSE=$(curl -X PUT \
-F "file=@${SCRIPT_DIR}/${SCRIPT_NAME}" \
-F "metadata=${EXTRA_METADATA_JSON}" \
"http://localhost:8123/upload")
UPLOAD_EXIT_CODE=$?
echo "Upload response: ${UPLOAD_RESPONSE}"
echo "Upload exit code: ${UPLOAD_EXIT_CODE}"
if [ ${UPLOAD_EXIT_CODE} -ne 0 ]; then
die "Failed to upload object: curl returned ${UPLOAD_EXIT_CODE}"
fi
if ! echo "${UPLOAD_RESPONSE}" | jq -e . >/dev/null 2>&1; then
die "Invalid JSON response from upload: ${UPLOAD_RESPONSE}"
fi
OBJECT_HASH=$(echo ${UPLOAD_RESPONSE} | jq -r '.hash')
echo "Received hash: ${OBJECT_HASH}"
# Verify the object exists
echo "Verifying object exists..."
EXISTS_RESPONSE=$(curl -s "${BASE_URL}/exists/${BASE_TAG}:test2")
echo "Exists response: ${EXISTS_RESPONSE}"
# Get metadata and verify extra fields are preserved
METADATA_RESPONSE=$(curl -s "${BASE_URL}/metadata/${BASE_TAG}:test2")
if ! echo "${METADATA_RESPONSE}" | jq -r '.extra_field1' | grep -q 'value1'; then
echo "Retrieving metadata for ${BASE_TAG}:test2"
METADATA_RESPONSE=$(curl -s "${BASE_URL}/meta/${BASE_TAG}:test2")
CURL_EXIT_CODE=$?
echo "Curl exit code: ${CURL_EXIT_CODE}"
echo "Full metadata response: ${METADATA_RESPONSE}"
if [ ${CURL_EXIT_CODE} -ne 0 ]; then
die "Failed to retrieve metadata: curl returned ${CURL_EXIT_CODE}"
fi
if ! echo "${METADATA_RESPONSE}" | jq -e . >/dev/null 2>&1; then
die "Invalid JSON response: ${METADATA_RESPONSE}"
fi
if ! echo "${METADATA_RESPONSE}" | jq -r '.metadata.extra_field1' | grep -q 'value1'; then
die "extra_field1 not preserved in metadata"
fi
if ! echo "${METADATA_RESPONSE}" | jq -r '.extra_field2' | grep -q 'value2'; then
if ! echo "${METADATA_RESPONSE}" | jq -r '.metadata.extra_field2' | grep -q 'value2'; then
die "extra_field2 not preserved in metadata"
fi