|
|
@ -62,7 +62,7 @@ func TestEdits(t *testing.T) { |
|
|
|
var mtx sync.Mutex |
|
|
|
var mtx sync.Mutex |
|
|
|
received := []acedoc.Delta{} |
|
|
|
received := []acedoc.Delta{} |
|
|
|
|
|
|
|
|
|
|
|
doc, err := w.CH.client(contentPath) |
|
|
|
doc, err := w.CH.editSession(contentPath) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatal("error creating document client:", err) |
|
|
|
t.Fatal("error creating document client:", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -75,7 +75,7 @@ func TestEdits(t *testing.T) { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
})) |
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
_, ok := w.CH.hasdocref(contentPath) |
|
|
|
_, ok := w.CH.hasEditSession(contentPath) |
|
|
|
if !ok { |
|
|
|
if !ok { |
|
|
|
t.Fatal("expected there to be an established client") |
|
|
|
t.Fatal("expected there to be an established client") |
|
|
|
} |
|
|
|
} |
|
|
@ -158,12 +158,12 @@ func TestDeltasSingle(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
client := new(WebsocketTester) |
|
|
|
client := new(WebsocketTester) |
|
|
|
|
|
|
|
|
|
|
|
doc, err := w.CH.client("content/" + title + ".md") |
|
|
|
doc, 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.handleConn(client, doc) |
|
|
|
go w.CH.handleDeltaConn(client, doc) |
|
|
|
|
|
|
|
|
|
|
|
a := acedoc.Insert(0, 0, "a") |
|
|
|
a := acedoc.Insert(0, 0, "a") |
|
|
|
|
|
|
|
|
|
|
@ -199,13 +199,13 @@ func TestDeltasDouble(t *testing.T) { |
|
|
|
clientA := new(WebsocketTester) |
|
|
|
clientA := new(WebsocketTester) |
|
|
|
clientB := new(WebsocketTester) |
|
|
|
clientB := new(WebsocketTester) |
|
|
|
|
|
|
|
|
|
|
|
doc, err := w.CH.client("content/" + title + ".md") |
|
|
|
doc, 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.handleConn(clientA, doc) |
|
|
|
go w.CH.handleDeltaConn(clientA, doc) |
|
|
|
go w.CH.handleConn(clientB, doc) |
|
|
|
go w.CH.handleDeltaConn(clientB, doc) |
|
|
|
|
|
|
|
|
|
|
|
// send the first message, simulating the browser on clientA
|
|
|
|
// send the first message, simulating the browser on clientA
|
|
|
|
clientA.ReceiveJSON(w.CH.Message(acedoc.Insert(0, 0, "a"))) |
|
|
|
clientA.ReceiveJSON(w.CH.Message(acedoc.Insert(0, 0, "a"))) |
|
|
@ -266,14 +266,14 @@ func TestDeltasMulti(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
clients := []*WebsocketTester{{}, {}, {}} |
|
|
|
clients := []*WebsocketTester{{}, {}, {}} |
|
|
|
|
|
|
|
|
|
|
|
doc, err := w.CH.client("content/" + title + ".md") |
|
|
|
doc, err := w.CH.editSession("content/" + title + ".md") |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatal("couldn't establish docref:", err) |
|
|
|
t.Fatal("couldn't establish docref:", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
go w.CH.handleConn(clients[0], doc) |
|
|
|
go w.CH.handleDeltaConn(clients[0], doc) |
|
|
|
go w.CH.handleConn(clients[1], doc) |
|
|
|
go w.CH.handleDeltaConn(clients[1], doc) |
|
|
|
go w.CH.handleConn(clients[2], doc) |
|
|
|
go w.CH.handleDeltaConn(clients[2], doc) |
|
|
|
|
|
|
|
|
|
|
|
a := acedoc.Insert(0, 0, "a") |
|
|
|
a := acedoc.Insert(0, 0, "a") |
|
|
|
b := acedoc.Insert(0, 0, "b") |
|
|
|
b := acedoc.Insert(0, 0, "b") |
|
|
|