优化jdapi.CallbackMsg

This commit is contained in:
gazebo
2019-12-07 23:52:35 +08:00
parent 61176c2618
commit bd0285aaf3
3 changed files with 49 additions and 13 deletions

View File

@@ -13,10 +13,11 @@ import (
func TestGetCallbackMsg(t *testing.T) {
for _, strPair := range [][]string{
[]string{
CallbackMsgOrderAccounting,
"newOrder",
`
timestamp=2019-12-03+06%3A28%3A40&sign=84AF173723A89E95AD7D0CFECA293683&v=1.0&jd_param_json=%7B%22billId%22%3A%22929053552000142%22%2C%22statusId%22%3A%2232000%22%2C%22timestamp%22%3A%222019-12-03+06%3A28%3A37%22%7D&token=77e703b7-7997-441b-a12a-2e522efb117a&app_key=1dba76d40cac446ca500c0391a0b6c9d&format=json
`,
timestamp=2019-12-07+06%3A27%3A42&sign=565F552F7BD692664A24C0F869A2FEC5&v=1.0&jd_param_json=%7B%22billId%22%3A%221100001049331247%22%2C%22statusId%22%3A%2232000%22%2C%22timestamp%22%3A%222019-12-07+06%3A27%3A38%22%7D&token=77e703b7-7997-441b-a12a-2e522efb117a&app_key=1dba76d40cac446ca500c0391a0b6c9d&format=json
`,
},
[]string{
CallbackMsgPushDeliveryStatus,
@@ -32,10 +33,11 @@ func TestGetCallbackMsg(t *testing.T) {
},
} {
callbackStr := strings.TrimSpace(strPair[1])
callbackMsg, mapData, resp := GetCallbackMsg2(utils.BuildRequest(http.MethodPost, strPair[0], callbackStr, ""))
callbackMsg, mapData, resp := GetCallbackMsg2(utils.BuildRequest(http.MethodPost, "/djsw/"+strPair[0], callbackStr, ""))
if resp != nil {
t.Fatal(resp)
}
sugarLogger.Debug(callbackMsg.MsgURL)
resp = api.CheckCallbackValidation2(mapData, callbackMsg.Sign)
if resp != nil {
t.Fatal(resp)
@@ -44,6 +46,26 @@ func TestGetCallbackMsg(t *testing.T) {
}
}
func TestGetOrderCallbackMsg(t *testing.T) {
callbackStr := strings.TrimSpace(
`
timestamp=2019-12-03+06%3A28%3A40&sign=84AF173723A89E95AD7D0CFECA293683&v=1.0&jd_param_json=%7B%22billId%22%3A%22929053552000142%22%2C%22statusId%22%3A%2232000%22%2C%22timestamp%22%3A%222019-12-03+06%3A28%3A37%22%7D&token=77e703b7-7997-441b-a12a-2e522efb117a&app_key=1dba76d40cac446ca500c0391a0b6c9d&format=json
`)
values, token, msgURL, resp := GetCallbackMsg(utils.BuildRequest(http.MethodPost, "/djsw/"+CallbackMsgOrderAccounting, callbackStr, ""), false)
if resp != nil {
t.Fatal(resp)
}
sugarLogger.Debug(token)
sugarLogger.Debug(msgURL)
orderMsg, resp := api.GetOrderCallbackMsg(values, msgURL)
if resp != nil {
t.Fatal(resp)
}
sugarLogger.Debug(utils.Format4Output(orderMsg, false))
sugarLogger.Debug(orderMsg.MsgURL)
}
func TestSimulateSendNewOrderMsg(t *testing.T) {
orderInfo := &CallbackOrderMsg{
BillID: "813344594000041",