Testing MultiChannel Response Condition in Channel Manage

This commit is contained in:
Sarah Jamie Lewis 2018-01-12 12:37:45 -05:00
parent 6e2bfbbc14
commit 30808c71b2
1 changed files with 28 additions and 0 deletions

View File

@ -5,6 +5,34 @@ import (
"testing"
)
type OverrideChatChannel struct {
channels.ChatChannel
}
// Singleton - for chat channels there can only be one instance per direction
func (cc *OverrideChatChannel) Singleton() bool {
return false
}
func TestClientManagerDuplicateMultiple(t *testing.T) {
ccm := NewClientChannelManager()
chatChannel := new(OverrideChatChannel)
_, err := ccm.OpenChannelRequestFromPeer(2, chatChannel)
if err != nil {
t.Errorf("Opening ChatChannel should have succeeded, instead: %v", err)
}
_, err = ccm.OpenChannelRequestFromPeer(4, chatChannel)
if err != nil {
t.Errorf("Opening ChatChannel should have succeeded, instead: %v", err)
}
channel := ccm.Channel("im.ricochet.chat", channels.Inbound)
if channel != nil {
t.Errorf("Get ChatChannel should have failed because there are 2 of them")
}
}
func TestClientManagerDuplicateChannel(t *testing.T) {
ccm := NewClientChannelManager()
chatChannel := new(channels.ChatChannel)