Bug fixing

This commit is contained in:
Your Name
2025-05-25 12:32:06 +12:00
parent 9308f4d719
commit 477d06d3bf
6 changed files with 261 additions and 207 deletions

35
test.sh
View File

@@ -54,9 +54,9 @@ BASE_TAG="autotest"
# Construct metadata JSON
METADATA_JSON=$(cat <<EOF
{
"labeltag": "${BASE_TAG}:test1",
"labels": ["${BASE_TAG}"],
"tags": ["test1"],
"description": "Example file",
"tags": ["test", "example"],
"custom_field": "custom value"
}
EOF
@@ -74,10 +74,6 @@ echo "upload response: ${UPLOAD_RESPONSE}"
OBJECT_HASH=$(echo ${UPLOAD_RESPONSE} | jq -r '.hash')
#OBJECT_HASH=$(curl -s "${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}"
# check the hash matches.
CHECK_HASH=$(curl -s "${BASE_URL}/hash/${BASE_TAG}:test1" | jq -r '.hash')
[ "${OBJECT_HASH}" != "${CHECK_HASH}" ] && die "hash does not match: ${OBJECT_HASH} != ${CHECK_HASH}"
@@ -108,7 +104,6 @@ MD5SUM_DOWNLOADED2=$(md5sum ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded2 | awk '{pri
rm ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1
rm ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded2
# delete the object
echo "deleting ${OBJECT_HASH}"
if ! curl -s -H "Authorization: Bearer ${WRITE_TOKEN}" "${BASE_URL}/deleteobject?hash=${OBJECT_HASH}" | jq -r '.result' | grep -q 'success'; then
@@ -128,9 +123,9 @@ title "Testing metadata field preservation"
# Upload with extra metadata fields
EXTRA_METADATA_JSON=$(cat <<EOF
{
"labeltag": "${BASE_TAG}:test2",
"labels": ["${BASE_TAG}"],
"tags": ["test2"],
"description": "Test with extra fields",
"tags": ["test", "extra"],
"custom_field": "custom value",
"extra_field1": "value1",
"extra_field2": "value2"
@@ -195,9 +190,9 @@ title "Testing tag versioning behavior"
# Upload first version with tag 'latest'
FIRST_METADATA_JSON=$(cat <<EOF
{
"labeltag": "${BASE_TAG}:latest",
"description": "First version",
"tags": ["test", "v1"]
"labels": ["${BASE_TAG}"],
"tags": ["latest", "v1"],
"description": "First version"
}
EOF
)
@@ -221,9 +216,9 @@ fi
# Upload second version with same tag 'latest'
SECOND_METADATA_JSON=$(cat <<EOF
{
"labeltag": "${BASE_TAG}:latest",
"description": "Second version",
"tags": ["test", "v2"]
"labels": ["${BASE_TAG}"],
"tags": ["latest", "v2"],
"description": "Second version"
}
EOF
)
@@ -248,15 +243,12 @@ if ! echo "${FIRST_METADATA}" | jq -r '.metadata.tags[]' | grep -q 'v1'; then
die "First version does not have v1 tag"
fi
# Verify first version's metadata no longer has the latest or test tags.
# Verify first version's metadata no longer has the latest tag
if echo "${FIRST_METADATA}" | jq -r '.metadata.tags[]' | grep -q 'latest'; then
die "First version still has latest tag"
fi
if echo "${FIRST_METADATA}" | jq -r '.metadata.tags[]' | grep -q 'test'; then
die "First version still has test tag"
fi
# Verify second version has the correct tags: v2, latest, test!
# Verify second version has the correct tags: v2 and latest
SECOND_METADATA=$(curl -s "${BASE_URL}/meta/${BASE_TAG}:latest")
echo "Second version metadata response: ${SECOND_METADATA}"
if ! echo "${SECOND_METADATA}" | jq -r '.metadata.tags[]' | grep -q 'v2'; then
@@ -265,9 +257,6 @@ fi
if ! echo "${SECOND_METADATA}" | jq -r '.metadata.tags[]' | grep -q 'latest'; then
die "Second version does not have latest tag"
fi
if ! echo "${SECOND_METADATA}" | jq -r '.metadata.tags[]' | grep -q 'test'; then
die "Second version does not have test tag"
fi
# Clean up
curl -s -H "Authorization: Bearer ${WRITE_TOKEN}" "${BASE_URL}/deleteobject?hash=${FIRST_HASH}" > /dev/null