No need to export NewChannel function.

This commit is contained in:
claudemiro
2015-01-31 09:19:00 -03:00
parent eca114dcf1
commit cd2e58d0c5
4 changed files with 19 additions and 19 deletions
+1 -1
View File
@@ -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)
}
+8 -8
View File
@@ -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")
+1 -1
View File
@@ -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)}
+9 -9
View File
@@ -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) {