[BUGFIX] testting after change receiving message

This commit is contained in:
Martin/Geno 2019-06-06 21:12:21 +02:00
parent d0655b22e2
commit aceced844a
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
1 changed files with 12 additions and 37 deletions

View File

@ -1,7 +1,6 @@
package threema package threema
import ( import (
"errors"
"testing" "testing"
"github.com/o3ma/o3" "github.com/o3ma/o3"
@ -28,24 +27,18 @@ func createDummyAccount() Account {
return a return a
} }
/*
func TestReceive(t *testing.T) { func TestReceive(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
a := createDummyAccount() a := createDummyAccount()
// receiving/skip error
p, err := a.receiving(o3.ReceivedMsg{
Err: errors.New("dummy"),
})
assert.Nil(p)
assert.Error(err)
// nothing to receiving // nothing to receiving
p, err = a.receiving(o3.ReceivedMsg{}) p, err := a.receiving(nil)
assert.Nil(p) assert.Nil(p)
assert.Error(err) assert.Error(err)
} }
*/
func TestReceiveText(t *testing.T) { func TestReceiveText(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
@ -60,9 +53,7 @@ func TestReceiveText(t *testing.T) {
} }
txtMsg, err := o3.NewTextMessage(&session, threemaID, "Oojoh0Ah") txtMsg, err := o3.NewTextMessage(&session, threemaID, "Oojoh0Ah")
assert.NoError(err) assert.NoError(err)
p, err := a.receiving(o3.ReceivedMsg{ p, err := a.receiving(txtMsg)
Msg: txtMsg,
})
assert.NoError(err) assert.NoError(err)
xMSG, ok := p.(xmpp.Message) xMSG, ok := p.(xmpp.Message)
assert.True(ok) assert.True(ok)
@ -83,16 +74,12 @@ func TestReceiveAudio(t *testing.T) {
}, },
}*/ }*/
dataMsg := o3.AudioMessage{} dataMsg := o3.AudioMessage{}
_, err := a.receiving(o3.ReceivedMsg{ _, err := a.receiving(dataMsg)
Msg: dataMsg,
})
assert.Error(err) assert.Error(err)
a.threema.httpUploadPath = "/tmp" a.threema.httpUploadPath = "/tmp"
dataMsg = o3.AudioMessage{} dataMsg = o3.AudioMessage{}
_, err = a.receiving(o3.ReceivedMsg{ _, err = a.receiving(dataMsg)
Msg: dataMsg,
})
assert.Error(err) assert.Error(err)
} }
func TestReceiveImage(t *testing.T) { func TestReceiveImage(t *testing.T) {
@ -109,16 +96,12 @@ func TestReceiveImage(t *testing.T) {
}, },
}*/ }*/
imgMsg := o3.ImageMessage{} imgMsg := o3.ImageMessage{}
_, err := a.receiving(o3.ReceivedMsg{ _, err := a.receiving(imgMsg)
Msg: imgMsg,
})
assert.Error(err) assert.Error(err)
a.threema.httpUploadPath = "/tmp" a.threema.httpUploadPath = "/tmp"
imgMsg = o3.ImageMessage{} imgMsg = o3.ImageMessage{}
_, err = a.receiving(o3.ReceivedMsg{ _, err = a.receiving(imgMsg)
Msg: imgMsg,
})
assert.Error(err) assert.Error(err)
} }
@ -140,9 +123,7 @@ func TestReceiveDeliveryReceipt(t *testing.T) {
drm, err := o3.NewDeliveryReceiptMessage(&session, threemaID, msgID, o3.MSGDELIVERED) drm, err := o3.NewDeliveryReceiptMessage(&session, threemaID, msgID, o3.MSGDELIVERED)
assert.NoError(err) assert.NoError(err)
p, err := a.receiving(o3.ReceivedMsg{ p, err := a.receiving(drm)
Msg: drm,
})
assert.NoError(err) assert.NoError(err)
xMSG, ok := p.(xmpp.Message) xMSG, ok := p.(xmpp.Message)
assert.True(ok) assert.True(ok)
@ -150,18 +131,14 @@ func TestReceiveDeliveryReceipt(t *testing.T) {
assert.Equal("im4aeseeh1IbaQui", rr.ID) assert.Equal("im4aeseeh1IbaQui", rr.ID)
// receiving delivered -> not in cache // receiving delivered -> not in cache
p, err = a.receiving(o3.ReceivedMsg{ p, err = a.receiving(drm)
Msg: drm,
})
assert.NoError(err) assert.NoError(err)
assert.Nil(p) assert.Nil(p)
// receiving readed // receiving readed
drm, err = o3.NewDeliveryReceiptMessage(&session, threemaID, msgID, o3.MSGREAD) drm, err = o3.NewDeliveryReceiptMessage(&session, threemaID, msgID, o3.MSGREAD)
assert.NoError(err) assert.NoError(err)
p, err = a.receiving(o3.ReceivedMsg{ p, err = a.receiving(drm)
Msg: drm,
})
assert.NoError(err) assert.NoError(err)
xMSG, ok = p.(xmpp.Message) xMSG, ok = p.(xmpp.Message)
assert.True(ok) assert.True(ok)
@ -169,9 +146,7 @@ func TestReceiveDeliveryReceipt(t *testing.T) {
assert.Equal("im4aeseeh1IbaQui", cmdd.ID) assert.Equal("im4aeseeh1IbaQui", cmdd.ID)
// receiving delivered -> not in cache // receiving delivered -> not in cache
p, err = a.receiving(o3.ReceivedMsg{ p, err = a.receiving(drm)
Msg: drm,
})
assert.NoError(err) assert.NoError(err)
assert.Nil(p) assert.Nil(p)
} }