|
|
@ -35,13 +35,20 @@ func TestEdits(t *testing.T) { |
|
|
|
w.CH.NewContent(title, "") |
|
|
|
w.CH.NewContent(title, "") |
|
|
|
|
|
|
|
|
|
|
|
// start an edit session
|
|
|
|
// start an edit session
|
|
|
|
doc, err := w.CH.editSession(contentPath) |
|
|
|
es, 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) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// register an *extra* client that just adds to the received delta slice we're tracking
|
|
|
|
// register a client that we will use to push the deltas. we dont need
|
|
|
|
c := doc.doc.Client(acedoc.DeltaHandlerFunc(func(ds []acedoc.Delta) error { |
|
|
|
// to actually do anything to receive deltas here, though.
|
|
|
|
|
|
|
|
c := es.doc.Client(acedoc.DeltaHandlerFunc(func(ds []acedoc.Delta) error { |
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// register an *extra* client that just adds to the received delta
|
|
|
|
|
|
|
|
// slice we're tracking
|
|
|
|
|
|
|
|
es.doc.Client(acedoc.DeltaHandlerFunc(func(ds []acedoc.Delta) error { |
|
|
|
mtx.Lock() |
|
|
|
mtx.Lock() |
|
|
|
defer mtx.Unlock() |
|
|
|
defer mtx.Unlock() |
|
|
|
received = append(received, ds...) |
|
|
|
received = append(received, ds...) |
|
|
@ -66,8 +73,6 @@ func TestEdits(t *testing.T) { |
|
|
|
if len(received) != len(send) { |
|
|
|
if len(received) != len(send) { |
|
|
|
t.Errorf("expected %d deltas, received %d; expected: %v, received: %v", len(send), len(received), send, received) |
|
|
|
t.Errorf("expected %d deltas, received %d; expected: %v, received: %v", len(send), len(received), send, received) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
t.Log(w.CH.Contents()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestDeltasSingle(t *testing.T) { |
|
|
|
func TestDeltasSingle(t *testing.T) { |
|
|
|