diff --git a/ipe/app.go b/ipe/app.go index 4de6dfb..fcd21bf 100644 --- a/ipe/app.go +++ b/ipe/app.go @@ -187,7 +187,7 @@ func (a *App) FindOrCreateChannelByChannelID(n string) *Channel { c, err := a.FindChannelByChannelID(n) if err != nil { - c = NewChannel(n) + c = newChannel(n) a.AddChannel(c) } diff --git a/ipe/app_test.go b/ipe/app_test.go index 09461fb..c54ce5b 100644 --- a/ipe/app_test.go +++ b/ipe/app_test.go @@ -61,7 +61,7 @@ func TestFindConnection(t *testing.T) { func TestFindChannelByChannelID(t *testing.T) { app := newApp() - channel := NewChannel("ID") + channel := newChannel("ID") app.AddChannel(channel) if _, err := app.FindChannelByChannelID("ID"); err != nil { @@ -91,7 +91,7 @@ func TestRemoveChannel(t *testing.T) { t.Error("Length of channels must be 0 before test") } - channel := NewChannel("ID") + channel := newChannel("ID") app.AddChannel(channel) if len(app.Channels) != 1 { @@ -116,7 +116,7 @@ func Test_add_channels(t *testing.T) { t.Error("Length of public channels must be 0 before test") } - app.AddChannel(NewChannel("ID")) + app.AddChannel(newChannel("ID")) if len(app.PublicChannels()) != 1 { t.Error("Length os public channels after insert must be 1") @@ -128,7 +128,7 @@ func Test_add_channels(t *testing.T) { t.Error("Length of presence channels must be 0 before test") } - app.AddChannel(NewChannel("presence-test")) + app.AddChannel(newChannel("presence-test")) if len(app.PresenceChannels()) != 1 { t.Error("Length os presence channels after insert must be 1") @@ -140,7 +140,7 @@ func Test_add_channels(t *testing.T) { t.Error("Length of private channels must be 0 before test") } - app.AddChannel(NewChannel("private-test")) + app.AddChannel(newChannel("private-test")) if len(app.PrivateChannels()) != 1 { t.Error("Length os private channels after insert must be 1") @@ -150,9 +150,9 @@ func Test_add_channels(t *testing.T) { func Test_AllChannels(t *testing.T) { app := newApp() - app.AddChannel(NewChannel("private-test")) - app.AddChannel(NewChannel("presence-test")) - app.AddChannel(NewChannel("test")) + app.AddChannel(newChannel("private-test")) + app.AddChannel(newChannel("presence-test")) + app.AddChannel(newChannel("test")) if len(app.Channels) != 3 { t.Error("Must have 3 channels") diff --git a/ipe/channel.go b/ipe/channel.go index 4d5c183..24acbc5 100644 --- a/ipe/channel.go +++ b/ipe/channel.go @@ -169,7 +169,7 @@ func (c *Channel) Unsubscribe(a *App, conn *Connection) error { } // Create a new Channel -func NewChannel(channelID string) *Channel { +func newChannel(channelID string) *Channel { log.Infof("Creating a new channel: %s", channelID) return &Channel{ChannelID: channelID, CreatedAt: time.Now(), Subscriptions: make(map[string]*Subscription)} diff --git a/ipe/channel_test.go b/ipe/channel_test.go index 7134941..974d702 100644 --- a/ipe/channel_test.go +++ b/ipe/channel_test.go @@ -7,7 +7,7 @@ package ipe import "testing" func TestIsOccupied(t *testing.T) { - c := NewChannel("ID") + c := newChannel("ID") if c.IsOccupied() { t.Error("Channels must be empty") @@ -21,7 +21,7 @@ func TestIsOccupied(t *testing.T) { } func TestIsPrivate(t *testing.T) { - c := NewChannel("private-channel") + c := newChannel("private-channel") if !c.IsPrivate() { t.Error("The Channel must be private") @@ -29,7 +29,7 @@ func TestIsPrivate(t *testing.T) { } func TestIsPresence(t *testing.T) { - c := NewChannel("presence-channel") + c := newChannel("presence-channel") if !c.IsPresence() { t.Error("The Channel must be presence") @@ -37,7 +37,7 @@ func TestIsPresence(t *testing.T) { } func TestIsPublic(t *testing.T) { - c := NewChannel("channel") + c := newChannel("channel") if !c.IsPublic() { t.Error("The Channel must be public") @@ -45,13 +45,13 @@ func TestIsPublic(t *testing.T) { } func TestIsPrivateOrPresence(t *testing.T) { - c := NewChannel("private-channel") + c := newChannel("private-channel") if !c.IsPresenceOrPrivate() { t.Error("The Channel must be private or presence") } - c = NewChannel("presence-channel") + c = newChannel("presence-channel") if !c.IsPresenceOrPrivate() { t.Error("The Channel must be private or presence") @@ -59,7 +59,7 @@ func TestIsPrivateOrPresence(t *testing.T) { } func TestTotalSubscriptions(t *testing.T) { - c := NewChannel("ID") + c := newChannel("ID") if c.TotalSubscriptions() != len(c.Subscriptions) { t.Error("TotalSubscriptions must be equal to len of total subscriptions") @@ -67,7 +67,7 @@ func TestTotalSubscriptions(t *testing.T) { } func TestTotalUsers(t *testing.T) { - c := NewChannel("ID") + c := newChannel("ID") c.Subscriptions["1"] = newSubscription(newConnection("ID", nil), "") c.Subscriptions["2"] = newSubscription(newConnection("ID", nil), "") @@ -83,7 +83,7 @@ func TestTotalUsers(t *testing.T) { } func TestIsSubscribed(t *testing.T) { - c := NewChannel("ID") + c := newChannel("ID") conn := newConnection("ID", nil) if c.IsSubscribed(conn) {