pull/1532/head
AndrewZuo01 2 years ago
parent f21bdcd9d8
commit 8d4f3e3564

@ -529,27 +529,36 @@ EOF
openim::test::check_error "$response" openim::test::check_error "$response"
} }
# Updates the pin status of a friend. # Updates the pin status of multiple friends.
openim::test::update_pin_status() { openim::test::update_pin_status() {
local ownerUserID="${1}" local ownerUserID="${1}"
local friendUserID="${2}" shift # Shift the arguments to skip the first one (ownerUserID)
local isPinned="${3}" local isPinned="${1}"
shift # Shift the arguments to skip the isPinned argument
# Constructing the list of friendUserIDs
local friendUserIDsArray=()
for friendUserID in "$@"; do
friendUserIDsArray+=("\"${friendUserID}\"")
done
local friendUserIDs=$(IFS=,; echo "${friendUserIDsArray[*]}")
local request_body=$(cat <<EOF local request_body=$(cat <<EOF
{ {
"ownerUserID": "${ownerUserID}", "ownerUserID": "${ownerUserID}",
"friendUserID": "${friendUserID}", "friendUserIDs": [${friendUserIDs}],
"isPinned": ${isPinned} "isPinned": ${isPinned}
} }
EOF EOF
) )
echo "Requesting to update pin status: $request_body" echo "Requesting to update pin status: $request_body"
local response=$(${CCURL} "${Token}" "${OperationID}" "${Header}" "${INSECURE_OPENIMAPI}/friend/set_pin_friend" -d "${request_body}") local response=$(${CCURL} "${Token}" "${OperationID}" "${Header}" "${INSECURE_OPENIMAPI}/friend/update_pin_status" -d "${request_body}")
openim::test::check_error "$response" openim::test::check_error "$response"
} }
# [openim::test::friend function description] # [openim::test::friend function description]
# The `openim::test::friend` function serves as a test suite for friend-related operations. # The `openim::test::friend` function serves as a test suite for friend-related operations.
# It sequentially invokes all friend-related test functions to ensure the API's friend operations are functioning correctly. # It sequentially invokes all friend-related test functions to ensure the API's friend operations are functioning correctly.
@ -605,8 +614,10 @@ function openim::test::friend() {
# 13. pin Friend # 13. pin Friend
# Add this call to your test suite where appropriate # Add this call to your test suite where appropriate
openim::test::update_pin_status "${TEST_USER_ID}" "${FRIEND_USER_ID}" true openim::test::update_pin_status "${TEST_USER_ID}" true ${FRIEND_USER_ID}
openim::test::update_pin_status "${TEST_USER_ID}" "${FRIEND_USER_ID}" false
openim::test::update_pin_status "${TEST_USER_ID}" false ${FRIEND_USER_ID}
# Log the completion of the friend test suite. # Log the completion of the friend test suite.
openim::log::success "Friend test suite completed successfully." openim::log::success "Friend test suite completed successfully."
} }

Loading…
Cancel
Save