fixing tests
This commit is contained in:
@@ -40,7 +40,6 @@ func (ch *CaddyHugo) ShouldApply(ltime uint64) bool {
|
||||
defer ch.mtx.Unlock()
|
||||
|
||||
if _, ok := ch.confirmingToClient[ltime]; ok {
|
||||
fmt.Println("rejecting ltime", ltime, "because was already processed")
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -153,7 +152,6 @@ func (ch *CaddyHugo) handleDeltaConn(conn DeltaConn, doc *editSession) (int, err
|
||||
client := doc.doc.Client(acedoc.DeltaHandlerFunc(func(ds []acedoc.Delta) error {
|
||||
m := ch.Message(ds...)
|
||||
wroteMessagesCh <- m
|
||||
fmt.Println("WRITING")
|
||||
return conn.WriteJSON(m)
|
||||
}))
|
||||
|
||||
@@ -189,7 +187,6 @@ func (ch *CaddyHugo) handleDeltaConn(conn DeltaConn, doc *editSession) (int, err
|
||||
if !ch.ShouldApply(message.LTime) {
|
||||
continue
|
||||
}
|
||||
fmt.Printf("READ %p\n", conn)
|
||||
|
||||
err = client.PushDeltas(message.Deltas...)
|
||||
if err != nil {
|
||||
|
||||
+9
-8
@@ -88,12 +88,12 @@ func TestDeltasSingle(t *testing.T) {
|
||||
|
||||
client := new(WebsocketTester)
|
||||
|
||||
doc, err := w.CH.editSession("content/" + title + ".md")
|
||||
es, err := w.CH.editSession("content/" + title + ".md")
|
||||
if err != nil {
|
||||
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")
|
||||
|
||||
@@ -104,9 +104,10 @@ func TestDeltasSingle(t *testing.T) {
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
|
||||
// we shouldn't have written back to the client,
|
||||
// so we expect to have written 0 messages
|
||||
if len(client.wroteMessages) != 0 {
|
||||
t.Errorf("client wrote %d messages, should have written %d", len(client.wroteMessages), 0)
|
||||
// so we expect to have written 0 *deltas*. (we may have written
|
||||
// empty messages without deltas because of the pings to the client)
|
||||
if len(client.wroteDeltas) != 0 {
|
||||
t.Errorf("client wrote %d deltas, should have written %d", len(client.wroteMessages), 0)
|
||||
t.Logf("%v", client.wroteMessages)
|
||||
}
|
||||
|
||||
@@ -148,7 +149,7 @@ func TestDeltasDouble(t *testing.T) {
|
||||
|
||||
// so we expect clientA to have written 0 messages, and
|
||||
// clientB to have written 1
|
||||
if len(clientA.wroteMessages) != 0 || len(clientB.wroteMessages) != 1 {
|
||||
if len(clientA.wroteDeltas) != 0 || len(clientB.wroteDeltas) != 1 {
|
||||
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()
|
||||
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
|
||||
if len(clientA.wroteMessages) != 1 || len(clientB.wroteMessages) != 1 {
|
||||
if len(clientA.wroteDeltas) != 1 || len(clientB.wroteDeltas) != 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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user