fix tests?

This commit is contained in:
Martin/Geno 2019-09-06 05:30:56 +02:00 committed by genofire
parent 93b7dc12f6
commit 836efe59a4
2 changed files with 15 additions and 15 deletions

View File

@ -45,7 +45,7 @@ func TestReceiveText(t *testing.T) {
a := createDummyAccount() a := createDummyAccount()
// receiving text // receiving text
txtMsg := o3.TextMessage{ txtMsg := &o3.TextMessage{
MessageHeader: &o3.MessageHeader{ MessageHeader: &o3.MessageHeader{
Sender: threemaFromIDByte, Sender: threemaFromIDByte,
Recipient: o3.NewIDString("12345678"), Recipient: o3.NewIDString("12345678"),
@ -117,7 +117,7 @@ func TestReceiveDeliveryReceipt(t *testing.T) {
a.deliveredMSG[msgID] = "im4aeseeh1IbaQui" a.deliveredMSG[msgID] = "im4aeseeh1IbaQui"
a.readedMSG[msgID] = "im4aeseeh1IbaQui" a.readedMSG[msgID] = "im4aeseeh1IbaQui"
drm := o3.DeliveryReceiptMessage{ drm := &o3.DeliveryReceiptMessage{
MessageHeader: &o3.MessageHeader{ MessageHeader: &o3.MessageHeader{
Sender: threemaFromIDByte, Sender: threemaFromIDByte,
}, },
@ -138,7 +138,7 @@ func TestReceiveDeliveryReceipt(t *testing.T) {
assert.Nil(p) assert.Nil(p)
// receiving readed // receiving readed
drm = o3.DeliveryReceiptMessage{ drm = &o3.DeliveryReceiptMessage{
MessageHeader: &o3.MessageHeader{ MessageHeader: &o3.MessageHeader{
Sender: threemaFromIDByte, Sender: threemaFromIDByte,
}, },
@ -164,7 +164,7 @@ func TestReceiveTyping(t *testing.T) {
a := createDummyAccount() a := createDummyAccount()
// receiving inactive // receiving inactive
tnm := o3.TypingNotificationMessage{ tnm := &o3.TypingNotificationMessage{
MessageHeader: &o3.MessageHeader{ MessageHeader: &o3.MessageHeader{
Sender: threemaFromIDByte, Sender: threemaFromIDByte,
}, },
@ -177,7 +177,7 @@ func TestReceiveTyping(t *testing.T) {
assert.IsType(stanza.StateInactive{}, xMSG.Extensions[0]) assert.IsType(stanza.StateInactive{}, xMSG.Extensions[0])
// receiving composing // receiving composing
tnm = o3.TypingNotificationMessage{ tnm = &o3.TypingNotificationMessage{
MessageHeader: &o3.MessageHeader{ MessageHeader: &o3.MessageHeader{
Sender: threemaFromIDByte, Sender: threemaFromIDByte,
}, },

View File

@ -13,7 +13,7 @@ func TestAccountSend(t *testing.T) {
send := make(chan o3.Message) send := make(chan o3.Message)
a := Account{ a := Account{
Session: o3.NewSessionContext(o3.ThreemaID{ID: o3.NewIDString("43218765")}), ThreemaID: &o3.ThreemaID{ID: o3.NewIDString("43218765")},
send: send, send: send,
deliveredMSG: make(map[uint64]string), deliveredMSG: make(map[uint64]string),
readedMSG: make(map[uint64]string), readedMSG: make(map[uint64]string),
@ -27,7 +27,7 @@ func TestAccountSend(t *testing.T) {
}() }()
p := <-send p := <-send
assert.NotNil(p) assert.NotNil(p)
msg := p.(o3.TextMessage) msg := p.(*o3.TextMessage)
assert.Contains(msg.Body, "ohz8kai0ohNgohth") assert.Contains(msg.Body, "ohz8kai0ohNgohth")
// test error // test error
@ -44,7 +44,7 @@ func TestAccountSendingDeliviery(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
a := Account{ a := Account{
Session: o3.NewSessionContext(o3.ThreemaID{ID: o3.NewIDString("43218765")}), ThreemaID: &o3.ThreemaID{ID: o3.NewIDString("43218765")},
} }
// test error - threema send only int ids // test error - threema send only int ids
@ -65,7 +65,7 @@ func TestAccountSendingDeliviery(t *testing.T) {
}, },
}) })
assert.NoError(err) assert.NoError(err)
drm, ok := msg.(o3.DeliveryReceiptMessage) drm, ok := msg.(*o3.DeliveryReceiptMessage)
assert.True(ok) assert.True(ok)
assert.Equal(o3.MSGDELIVERED, drm.Status) assert.Equal(o3.MSGDELIVERED, drm.Status)
@ -77,7 +77,7 @@ func TestAccountSendingDeliviery(t *testing.T) {
}, },
}) })
assert.NoError(err) assert.NoError(err)
drm, ok = msg.(o3.DeliveryReceiptMessage) drm, ok = msg.(*o3.DeliveryReceiptMessage)
assert.True(ok) assert.True(ok)
assert.Equal(o3.MSGREAD, drm.Status) assert.Equal(o3.MSGREAD, drm.Status)
} }
@ -85,12 +85,12 @@ func TestSendTyping(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
a := Account{ a := Account{
Session: o3.NewSessionContext(o3.ThreemaID{ID: o3.NewIDString("43218765")}), ThreemaID: &o3.ThreemaID{ID: o3.NewIDString("43218765")},
deliveredMSG: make(map[uint64]string), deliveredMSG: make(map[uint64]string),
readedMSG: make(map[uint64]string), readedMSG: make(map[uint64]string),
} }
// skip typing messae // skip typing message
msg, err := a.sending("a", stanza.Message{ msg, err := a.sending("a", stanza.Message{
Attrs: stanza.Attrs{From: "a@example.org"}, Attrs: stanza.Attrs{From: "a@example.org"},
Extensions: []stanza.MsgExtension{ Extensions: []stanza.MsgExtension{
@ -98,7 +98,7 @@ func TestSendTyping(t *testing.T) {
}, },
}) })
assert.NoError(err) assert.NoError(err)
assert.Nil(msg) assert.NotNil(msg)
// skip gone // skip gone
msg, err = a.sending("a", stanza.Message{ msg, err = a.sending("a", stanza.Message{
@ -111,7 +111,7 @@ func TestSendTyping(t *testing.T) {
}, },
}) })
assert.NoError(err) assert.NoError(err)
assert.Nil(msg) assert.NotNil(msg)
// skip gone // skip gone
msg, err = a.sending("a", stanza.Message{ msg, err = a.sending("a", stanza.Message{
@ -127,6 +127,6 @@ func TestSendTyping(t *testing.T) {
}) })
assert.NoError(err) assert.NoError(err)
assert.NotNil(msg) assert.NotNil(msg)
o3msg := msg.(o3.TextMessage) o3msg := msg.(*o3.TextMessage)
assert.Contains(o3msg.Body, "hi") assert.Contains(o3msg.Body, "hi")
} }