Bug fixing
This commit is contained in:
30
test.sh
30
test.sh
@@ -62,8 +62,7 @@ echo "Simple Object Storage server is running at ${BASE_URL}"
|
||||
# Construct metadata JSON
|
||||
METADATA_JSON=$(cat <<EOF
|
||||
{
|
||||
"labels": ["${BASE_TAG}"],
|
||||
"tags": ["test1"],
|
||||
"labeltags": ["${BASE_TAG}:test1"],
|
||||
"description": "Example file",
|
||||
"custom_field": "custom value"
|
||||
}
|
||||
@@ -133,8 +132,7 @@ title "Testing metadata field preservation"
|
||||
# Upload with extra metadata fields
|
||||
EXTRA_METADATA_JSON=$(cat <<EOF
|
||||
{
|
||||
"labels": ["${BASE_TAG}"],
|
||||
"tags": ["test2"],
|
||||
"labeltags": ["${BASE_TAG}:test2"],
|
||||
"description": "Test with extra fields",
|
||||
"custom_field": "custom value",
|
||||
"extra_field1": "value1",
|
||||
@@ -200,8 +198,7 @@ title "Testing tag versioning behavior"
|
||||
# Upload first version with tag 'latest'
|
||||
FIRST_METADATA_JSON=$(cat <<EOF
|
||||
{
|
||||
"labels": ["${BASE_TAG}"],
|
||||
"tags": ["latest", "v1"],
|
||||
"labeltags": ["${BASE_TAG}:latest", "${BASE_TAG}:v1"],
|
||||
"description": "First version"
|
||||
}
|
||||
EOF
|
||||
@@ -217,17 +214,16 @@ UPLOAD_RESPONSE=$(curl -X PUT \
|
||||
FIRST_HASH=$(echo ${UPLOAD_RESPONSE} | jq -r '.hash')
|
||||
|
||||
# Store first version's metadata before uploading second version
|
||||
FIRST_METADATA=$(curl -s "${BASE_URL}/meta/${BASE_TAG}:latest")
|
||||
FIRST_METADATA=$(curl -s "${BASE_URL}/meta/${FIRST_HASH}")
|
||||
echo "First version metadata response: ${FIRST_METADATA}"
|
||||
if ! echo "${FIRST_METADATA}" | jq -r '.metadata.tags[]' | grep -q 'v1'; then
|
||||
if ! echo "${FIRST_METADATA}" | jq -r '.metadata.labeltags[]' | grep -q "${BASE_TAG}:v1"; then
|
||||
die "First version does not have v1 tag"
|
||||
fi
|
||||
|
||||
# Upload second version with same tag 'latest'
|
||||
SECOND_METADATA_JSON=$(cat <<EOF
|
||||
{
|
||||
"labels": ["${BASE_TAG}"],
|
||||
"tags": ["latest", "v2"],
|
||||
"labeltags": ["${BASE_TAG}:latest", "${BASE_TAG}:v2"],
|
||||
"description": "Second version"
|
||||
}
|
||||
EOF
|
||||
@@ -249,24 +245,24 @@ SECOND_HASH=$(echo ${UPLOAD_RESPONSE} | jq -r '.hash')
|
||||
# Verify first version's metadata still has v1 tag
|
||||
FIRST_METADATA=$(curl -s "${BASE_URL}/meta/${FIRST_HASH}")
|
||||
echo "First version metadata response: ${FIRST_METADATA}"
|
||||
if ! echo "${FIRST_METADATA}" | jq -r '.metadata.tags[]' | grep -q 'v1'; then
|
||||
if ! echo "${FIRST_METADATA}" | jq -r '.metadata.labeltags[]' | grep -q "${BASE_TAG}:v1"; then
|
||||
die "First version does not have v1 tag"
|
||||
fi
|
||||
|
||||
# Verify first version's metadata no longer has the latest tag
|
||||
if echo "${FIRST_METADATA}" | jq -r '.metadata.tags[]' | grep -q 'latest'; then
|
||||
if echo "${FIRST_METADATA}" | jq -r '.metadata.labeltags[]' | grep -q "${BASE_TAG}:latest"; then
|
||||
die "First version still has latest tag"
|
||||
fi
|
||||
|
||||
# Verify second version has the correct tags: v2 and latest
|
||||
SECOND_METADATA=$(curl -s "${BASE_URL}/meta/${BASE_TAG}:latest")
|
||||
SECOND_METADATA=$(curl -s "${BASE_URL}/meta/${SECOND_HASH}")
|
||||
echo "Second version metadata response: ${SECOND_METADATA}"
|
||||
if ! echo "${SECOND_METADATA}" | jq -r '.metadata.tags[]' | grep -q 'v2'; then
|
||||
die "Second version does not have v2 tag"
|
||||
fi
|
||||
if ! echo "${SECOND_METADATA}" | jq -r '.metadata.tags[]' | grep -q 'latest'; then
|
||||
if ! echo "${SECOND_METADATA}" | jq -r '.metadata.labeltags[]' | grep -q "${BASE_TAG}:latest"; then
|
||||
die "Second version does not have latest tag"
|
||||
fi
|
||||
if ! echo "${SECOND_METADATA}" | jq -r '.metadata.labeltags[]' | grep -q "${BASE_TAG}:v2"; then
|
||||
die "Second version does not have v2 tag"
|
||||
fi
|
||||
|
||||
# Clean up
|
||||
curl -s -H "Authorization: Bearer ${WRITE_TOKEN}" "${BASE_URL}/deleteobject?hash=${FIRST_HASH}" > /dev/null
|
||||
|
Reference in New Issue
Block a user