Fixed tests
This commit is contained in:
+5
-5
@@ -23,7 +23,7 @@ func newApp() *App {
|
|||||||
func TestConnect(t *testing.T) {
|
func TestConnect(t *testing.T) {
|
||||||
app := newApp()
|
app := newApp()
|
||||||
|
|
||||||
app.Connect(NewConnection("socketID", nil))
|
app.Connect(newConnection("socketID", nil))
|
||||||
|
|
||||||
if len(app.Connections) != 1 {
|
if len(app.Connections) != 1 {
|
||||||
t.Errorf("Connections must be 1, but was %d", len(app.Connections))
|
t.Errorf("Connections must be 1, but was %d", len(app.Connections))
|
||||||
@@ -34,7 +34,7 @@ func TestConnect(t *testing.T) {
|
|||||||
func TestDisconnect(t *testing.T) {
|
func TestDisconnect(t *testing.T) {
|
||||||
app := newApp()
|
app := newApp()
|
||||||
|
|
||||||
app.Connect(NewConnection("socketID", nil))
|
app.Connect(newConnection("socketID", nil))
|
||||||
app.Disconnect("socketID")
|
app.Disconnect("socketID")
|
||||||
|
|
||||||
if len(app.Connections) != 0 {
|
if len(app.Connections) != 0 {
|
||||||
@@ -46,7 +46,7 @@ func TestDisconnect(t *testing.T) {
|
|||||||
func TestFindConnection(t *testing.T) {
|
func TestFindConnection(t *testing.T) {
|
||||||
app := newApp()
|
app := newApp()
|
||||||
|
|
||||||
app.Connect(NewConnection("socketID", nil))
|
app.Connect(newConnection("socketID", nil))
|
||||||
|
|
||||||
if _, err := app.FindConnection("socketID"); err != nil {
|
if _, err := app.FindConnection("socketID"); err != nil {
|
||||||
t.Error("Must find Connection")
|
t.Error("Must find Connection")
|
||||||
@@ -166,7 +166,7 @@ func Test_New_Subscriber(t *testing.T) {
|
|||||||
t.Error("Length of subscribers before test must be 0")
|
t.Error("Length of subscribers before test must be 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := NewConnection("1", nil)
|
conn := newConnection("1", nil)
|
||||||
app.Connect(conn)
|
app.Connect(conn)
|
||||||
|
|
||||||
if len(app.Connections) != 1 {
|
if len(app.Connections) != 1 {
|
||||||
@@ -176,7 +176,7 @@ func Test_New_Subscriber(t *testing.T) {
|
|||||||
|
|
||||||
func Test_find_subscriber(t *testing.T) {
|
func Test_find_subscriber(t *testing.T) {
|
||||||
app := newApp()
|
app := newApp()
|
||||||
conn := NewConnection("1", nil)
|
conn := newConnection("1", nil)
|
||||||
app.Connect(conn)
|
app.Connect(conn)
|
||||||
|
|
||||||
conn, err := app.FindConnection("1")
|
conn, err := app.FindConnection("1")
|
||||||
|
|||||||
+5
-5
@@ -13,7 +13,7 @@ func TestIsOccupied(t *testing.T) {
|
|||||||
t.Error("Channels must be empty")
|
t.Error("Channels must be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Subscriptions["ID"] = NewSubscription(NewConnection("ID", nil), "")
|
c.Subscriptions["ID"] = newSubscription(newConnection("ID", nil), "")
|
||||||
|
|
||||||
if !c.IsOccupied() {
|
if !c.IsOccupied() {
|
||||||
t.Error("Channels must be empty")
|
t.Error("Channels must be empty")
|
||||||
@@ -69,8 +69,8 @@ func TestTotalSubscriptions(t *testing.T) {
|
|||||||
func TestTotalUsers(t *testing.T) {
|
func TestTotalUsers(t *testing.T) {
|
||||||
c := NewChannel("ID")
|
c := NewChannel("ID")
|
||||||
|
|
||||||
c.Subscriptions["1"] = NewSubscription(NewConnection("ID", nil), "")
|
c.Subscriptions["1"] = newSubscription(newConnection("ID", nil), "")
|
||||||
c.Subscriptions["2"] = NewSubscription(NewConnection("ID", nil), "")
|
c.Subscriptions["2"] = newSubscription(newConnection("ID", nil), "")
|
||||||
|
|
||||||
if c.TotalSubscriptions() != len(c.Subscriptions) {
|
if c.TotalSubscriptions() != len(c.Subscriptions) {
|
||||||
t.Error("TotalSubscriptions must be equal to len of total subscriptions")
|
t.Error("TotalSubscriptions must be equal to len of total subscriptions")
|
||||||
@@ -84,13 +84,13 @@ func TestTotalUsers(t *testing.T) {
|
|||||||
|
|
||||||
func TestIsSubscribed(t *testing.T) {
|
func TestIsSubscribed(t *testing.T) {
|
||||||
c := NewChannel("ID")
|
c := NewChannel("ID")
|
||||||
conn := NewConnection("ID", nil)
|
conn := newConnection("ID", nil)
|
||||||
|
|
||||||
if c.IsSubscribed(conn) {
|
if c.IsSubscribed(conn) {
|
||||||
t.Error("Must not be subscribed")
|
t.Error("Must not be subscribed")
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Subscriptions["ID"] = NewSubscription(conn, "")
|
c.Subscriptions["ID"] = newSubscription(conn, "")
|
||||||
|
|
||||||
if !c.IsSubscribed(conn) {
|
if !c.IsSubscribed(conn) {
|
||||||
t.Error("Must be subscribed")
|
t.Error("Must be subscribed")
|
||||||
|
|||||||
Reference in New Issue
Block a user