docs: add openim search test (#1485)

pull/1408/head
Xinwei Xiong 7 months ago committed by GitHub
parent f935d36715
commit 100926da0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1168,6 +1168,40 @@ EOF
openim::test::check_error "$response"
}
# Searches for messages.
openim::test::search_msg() {
local sendID="${1}"
local recvID="${2}"
local msgType="${3}"
local sendTime="${4}"
local sessionType="${5}"
local pageNumber="${6}"
local showNumber="${7}"
# Construct the request body
local request_body=$(cat <<EOF
{
"sendID": "${sendID}",
"recvID": "${recvID}",
"msgType": ${msgType},
"sendTime": "${sendTime}",
"sessionType": ${sessionType},
"pagination": {
"pageNumber": ${pageNumber},
"showNumber": ${showNumber}
}
}
EOF
)
echo "$request_body"
# Send the request
local response=$(${CCURL} "${Token}" "${OperationID}" "${Header}" "${INSECURE_OPENIMAPI}/msg/search_msg" -d "${request_body}")
# Check the response for errors
openim::test::check_error "$response"
}
# Revokes a message.
openim::test::revoke_msg() {
local userID="${1}"
@ -1220,15 +1254,23 @@ function openim::test::msg()
# 0. Send a message.
openim::test::send_msg "${SEND_USER_ID}" "${RECV_USER_ID}" "${GROUP_ID}"
# Wait for a short duration to ensure message is sent
# 1. Search for the message
local SEARCH_TIME="2023-01-01T00:00:00Z" # You may need to adjust this
local MSG_TYPE=101
local SESSION_TYPE=1
local PAGE_NUMBER=1
local SHOW_NUMBER=20
echo "Searching for messages between ${SEND_USER_ID} and ${RECV_USER_ID}..."
openim::test::search_msg "${MANAGER_USERID_1}" "${RECV_USER_ID}" "${MSG_TYPE}" "${SEARCH_TIME}" "${SESSION_TYPE}" "${PAGE_NUMBER}" "${SHOW_NUMBER}"
# Assuming message sending was successful and returned a sequence number.
local SEQ_NUMBER=1 # This should be the actual sequence number of the message sent.
# 1. Revoke a message.
# 2. Revoke a message.
# TODO
# openim::test::revoke_msg "${RECV_USER_ID}" "si_${SEND_USER_ID}_${RECV_USER_ID}" "${SEQ_NUMBER}"
# 2. Clear all messages for a user.
# 3. Clear all messages for a user.
openim::test::user_clear_all_msg "${RECV_USER_ID}"
# Log the completion of the message test suite.
@ -1286,4 +1328,4 @@ openim::test::test() {
# functions to be triggered based on the passed arguments.
if [[ "$*" =~ openim::test:: ]];then
eval $*
fi
fi

Loading…
Cancel
Save