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