From ae08433f9edaec0cab34abc700d5eb75a4497287 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Tue, 27 Jul 2021 22:59:01 +0200 Subject: add bref augment scaffold --- skate/reduce_test.go | 40 ++++++++++++++++++++++++++++++++++++++++ skate/testdata/zippy/cB00a.json | 1 + skate/testdata/zippy/cB00b.json | 1 + skate/testdata/zippy/cB00r.json | 1 + 4 files changed, 43 insertions(+) create mode 100644 skate/testdata/zippy/cB00a.json create mode 100644 skate/testdata/zippy/cB00b.json create mode 100644 skate/testdata/zippy/cB00r.json diff --git a/skate/reduce_test.go b/skate/reduce_test.go index 172547b..65f3305 100644 --- a/skate/reduce_test.go +++ b/skate/reduce_test.go @@ -435,6 +435,46 @@ func TestZippyExact(t *testing.T) { } } +func TestZippyBrefAugment(t *testing.T) { + var cases = []struct { + a, b, out string + err error + }{ + { + a: "testdata/zippy/cB00a.json", + b: "testdata/zippy/cB00b.json", + out: "testdata/zippy/cB00r.json", + err: nil, + }, + } + timeNow = func() time.Time { + return time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC) + } + for i, c := range cases { + a, b, err := xio.OpenTwo(c.a, c.b) + if err != nil { + t.Errorf("failed to open test files: %v, %v", c.a, c.b) + } + var buf bytes.Buffer + err = ZippyBrefAugment(a, b, &buf) + if err != c.err { + t.Errorf("[%d] got %v, want %v", i, err, c.err) + } + ok, err := testutil.BufferFileEquals(&buf, c.out) + if err != nil { + t.Errorf("failed to open test file: %v", c.out) + } + if !ok { + filename, err := testutil.BufferToTemp(&buf) + if err != nil { + t.Logf("could not write temp file: %v", err) + } + t.Errorf("[%d] output mismatch (buffer length=%d, content=%v), want %v", + i, buf.Len(), filename, c.out) + } + } +} + func TestCutBatch(t *testing.T) { var cases = []struct { lines []string diff --git a/skate/testdata/zippy/cB00a.json b/skate/testdata/zippy/cB00a.json new file mode 100644 index 0000000..d6e46c7 --- /dev/null +++ b/skate/testdata/zippy/cB00a.json @@ -0,0 +1 @@ +123 {"source_release_ident": "123"} diff --git a/skate/testdata/zippy/cB00b.json b/skate/testdata/zippy/cB00b.json new file mode 100644 index 0000000..10715e8 --- /dev/null +++ b/skate/testdata/zippy/cB00b.json @@ -0,0 +1 @@ +123 {"biblio": {"title": "Hello"}} diff --git a/skate/testdata/zippy/cB00r.json b/skate/testdata/zippy/cB00r.json new file mode 100644 index 0000000..fd7356b --- /dev/null +++ b/skate/testdata/zippy/cB00r.json @@ -0,0 +1 @@ +{"_id":"123_0","indexed_ts":"1970-01-01T00:00:00Z","source_release_ident":"123"} -- cgit v1.2.3