From ba81e091aac2efe014111f64164d54ec92e8e549 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Wed, 27 Mar 2013 14:18:35 +0100 Subject: Implemented patching --- librsync/signature_test.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'librsync/signature_test.go') diff --git a/librsync/signature_test.go b/librsync/signature_test.go index 152fd12..e0fd50f 100644 --- a/librsync/signature_test.go +++ b/librsync/signature_test.go @@ -76,5 +76,23 @@ func TestSignatureDeltaPatch(t *testing.T) { } } - // TODO: Test patching + // Apply Patch + patchres := new(bytes.Buffer) + patcher, err := NewPatcher(deltabuf, orig) + if err != nil { + t.Fatalf("could not create a patcher: %s", err) + } + defer patcher.Close() + + if _, err = io.Copy(patchres, patcher); err != nil { + t.Fatalf("Applying the patch failed: %s", err) + } + + if !bytes.Equal(patchres.Bytes(), testdata.Mutation()) { + if path, err := dump(patchres); err == nil { + t.Fatalf("patch result and mutation are not equal. Result dumped to %s", path) + } else { + t.Fatalf("patch result and mutation are not equal. Could not dump result: %s", err) + } + } } -- cgit v1.2.3-70-g09d2