@ -88,12 +88,12 @@ func TestDeltasSingle(t *testing.T) {
client := new ( WebsocketTester )
client := new ( WebsocketTester )
doc , err := w . CH . editSession ( "content/" + title + ".md" )
es , err := w . CH . editSession ( "content/" + title + ".md" )
if err != nil {
if err != nil {
t . Fatal ( "couldn't establish docref for client 0:" , err )
t . Fatal ( "couldn't establish docref for client 0:" , err )
}
}
go w . CH . handleDeltaConn ( client , doc )
go w . CH . handleDeltaConn ( client , es )
a := acedoc . Insert ( 0 , 0 , "a" )
a := acedoc . Insert ( 0 , 0 , "a" )
@ -104,9 +104,10 @@ func TestDeltasSingle(t *testing.T) {
time . Sleep ( 50 * time . Millisecond )
time . Sleep ( 50 * time . Millisecond )
// we shouldn't have written back to the client,
// we shouldn't have written back to the client,
// so we expect to have written 0 messages
// so we expect to have written 0 *deltas*. (we may have written
if len ( client . wroteMessages ) != 0 {
// empty messages without deltas because of the pings to the client)
t . Errorf ( "client wrote %d messages, should have written %d" , len ( client . wroteMessages ) , 0 )
if len ( client . wroteDeltas ) != 0 {
t . Errorf ( "client wrote %d deltas, should have written %d" , len ( client . wroteMessages ) , 0 )
t . Logf ( "%v" , client . wroteMessages )
t . Logf ( "%v" , client . wroteMessages )
}
}
@ -148,7 +149,7 @@ func TestDeltasDouble(t *testing.T) {
// so we expect clientA to have written 0 messages, and
// so we expect clientA to have written 0 messages, and
// clientB to have written 1
// clientB to have written 1
if len ( clientA . wroteMessage s ) != 0 || len ( clientB . wroteMessage s ) != 1 {
if len ( clientA . wroteDelta s ) != 0 || len ( clientB . wroteDelta s ) != 1 {
t . Errorf ( "clientA wrote %d messages, should have written 0. clientB wrote %d, should have written 1" , len ( clientA . wroteMessages ) , len ( clientB . wroteMessages ) )
t . Errorf ( "clientA wrote %d messages, should have written 0. clientB wrote %d, should have written 1" , len ( clientA . wroteMessages ) , len ( clientB . wroteMessages ) )
}
}
@ -169,9 +170,9 @@ func TestDeltasDouble(t *testing.T) {
clientA . mtx . Lock ( )
clientA . mtx . Lock ( )
clientB . mtx . Lock ( )
clientB . mtx . Lock ( )
// so we expect clientA to have written 1 message this time, and
// so we expect clientA to have written 1 delta this time, and
// clientB to have written nothing new, so 1 still
// clientB to have written nothing new, so 1 still
if len ( clientA . wroteMessage s ) != 1 || len ( clientB . wroteMessage s ) != 1 {
if len ( clientA . wroteDelta s ) != 1 || len ( clientB . wroteDelta s ) != 1 {
t . Errorf ( "clientA wrote %d messages, should have written 1. clientB wrote %d, should have written 1 (just from before)" , len ( clientA . wroteMessages ) , len ( clientB . wroteMessages ) )
t . Errorf ( "clientA wrote %d messages, should have written 1. clientB wrote %d, should have written 1 (just from before)" , len ( clientA . wroteMessages ) , len ( clientB . wroteMessages ) )
}
}