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 53 54 55 56 57 58
|
package client
import (
"io/ioutil"
"log"
"testing"
"github.com/twstrike/gotk3adapter/glib_mock"
"github.com/twstrike/otr3"
"github.com/twstrike/coyim/i18n"
. "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
func init() {
log.SetOutput(ioutil.Discard)
i18n.InitLocalization(&glib_mock.Mock{})
}
type ConversationManagerSuite struct{}
var _ = Suite(&ConversationManagerSuite{})
type testSender struct {
peer, resource, msg string
err error
}
type testConvBuilder struct {
fake *otr3.Conversation
}
func (cb *testConvBuilder) NewConversation(peer string) *otr3.Conversation {
return cb.fake
}
func (ts *testSender) Send(peer, resource, msg string) error {
ts.peer = peer
ts.msg = msg
ts.resource = resource
return ts.err
}
func (s *ConversationManagerSuite) Test_TerminateAll_willTerminate(c *C) {
cb := &testConvBuilder{&otr3.Conversation{}}
ts := &testSender{err: nil}
mgr := NewConversationManager(cb, ts)
conv, created := mgr.EnsureConversationWith("someone@whitehouse.gov", "")
c.Assert(created, Equals, true)
c.Assert(conv, Not(IsNil))
mgr.TerminateAll()
c.Assert(ts.msg, Equals, "")
}
|