add test normal response for send message
This commit is contained in:
+4
-1
@@ -127,7 +127,10 @@ func GetMsgs(soap string) []string {
|
||||
func GetErrMsg(soap string) string {
|
||||
r, _ := regexp.Compile(errExp)
|
||||
msg := r.FindAllString(soap, -1)
|
||||
if len(msg) > 0 && len(msg[0]) > 40 {
|
||||
if len(msg) < 1 {
|
||||
return ""
|
||||
}
|
||||
if len(msg[0]) > 40 {
|
||||
size := len(msg[0])
|
||||
return msg[0][54 : size-15]
|
||||
}
|
||||
|
||||
@@ -94,6 +94,8 @@ const (
|
||||
Msg string = `<?xml version="1.0" encoding="UTF-8"?> <msg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="unisysaodbsis.xsd"> <meta> <sndr>AODB</sndr> <seqn>820830</seqn> <dttm>20180527124442</dttm> <type>FLOP</type> <styp>ESTT</styp> </meta> <flop> <flid>10725849</flid> <ffid>CA-CA4242-A-27MAY181955-D</ffid> <estt>27MAY181945</estt> </flop> </msg>`
|
||||
|
||||
ErrMsg string = `<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>invalid route envent id </faultstring><detail><BHIAFault xmlns="http://ciims.bhia.itdcl.com"><code xmlns="http://msg.ciims.bhia.itdcl.com">20</code><errorMessage xmlns="http://msg.ciims.bhia.itdcl.com">Can not find the event [FLOP-ESTT-ATC-ALL1]</errorMessage></BHIAFault></detail></soap:Fault></soap:Body></soap:Envelope>`
|
||||
|
||||
SendOk string = `<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><ns1:sendResponse xmlns:ns1="http://ciims.bhia.itdcl.com/ExchangeService" /></soap:Body></soap:Envelope>`
|
||||
)
|
||||
|
||||
func TestSend(t *testing.T) {
|
||||
@@ -126,3 +128,9 @@ func TestGetErrMsg(t *testing.T) {
|
||||
errMsg := GetErrMsg(ErrMsg)
|
||||
assert.Equal("Can not find the event [FLOP-ESTT-ATC-ALL1]", errMsg)
|
||||
}
|
||||
|
||||
func TestSendOk(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
errMsg := GetErrMsg(SendOk)
|
||||
assert.Equal("", errMsg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user