1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
package client
import (
"errors"
"github.com/twstrike/otr3"
)
import . "gopkg.in/check.v1"
type ConversationSuite struct{}
var _ = Suite(&ConversationSuite{})
func (s *ConversationSuite) Test_StartEncryptedChat_startsAnEncryptedChat(c *C) {
cb := &conversation{"foo@bar.com", "", &otr3.Conversation{}}
ts := &testSender{err: nil}
cb.SetFriendlyQueryMessage("Your peer has requested a private conversation with you, but your client doesn't seem to support the OTR protocol.")
e := cb.StartEncryptedChat(ts, "")
c.Assert(e, IsNil)
c.Assert(ts.peer, Equals, "foo@bar.com")
c.Assert(ts.msg, Equals, "?OTRv? Your peer has requested a private conversation with you, but your client doesn't seem to support the OTR protocol.")
}
func (s *ConversationSuite) Test_sendAll_returnsTheFirstErrorEncountered(c *C) {
cb := &conversation{"foo@bar.com", "", &otr3.Conversation{}}
ts := &testSender{err: errors.New("hello")}
e := cb.sendAll(ts, "", []otr3.ValidMessage{otr3.ValidMessage([]byte("Hello there"))})
c.Assert(e, DeepEquals, errors.New("hello"))
}
func (s *ConversationSuite) Test_sendAll_sendsTheMessageGiven(c *C) {
cb := &conversation{"foo@bar.com", "", &otr3.Conversation{}}
ts := &testSender{err: nil}
e := cb.sendAll(ts, "", []otr3.ValidMessage{otr3.ValidMessage([]byte("Hello there"))})
c.Assert(e, IsNil)
c.Assert(ts.peer, Equals, "foo@bar.com")
c.Assert(ts.msg, Equals, "Hello there")
}
func (s *ConversationSuite) Test_Send_(c *C) {
cb := &conversation{"foo@bar.com", "", &otr3.Conversation{}}
ts := &testSender{err: nil}
_, e := cb.Send(ts, "", []byte("Hello there"))
c.Assert(e, IsNil)
c.Assert(ts.peer, Equals, "foo@bar.com")
c.Assert(ts.msg, Equals, "Hello there")
}
|