diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-07-27 22:59:01 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-07-27 22:59:01 +0200 |
commit | ae08433f9edaec0cab34abc700d5eb75a4497287 (patch) | |
tree | 12537313c3533768eabe92b0c3aceaa630552364 /skate | |
parent | 694ac808eba5c0036343d4acc2d1692a54677645 (diff) | |
download | refcat-ae08433f9edaec0cab34abc700d5eb75a4497287.tar.gz refcat-ae08433f9edaec0cab34abc700d5eb75a4497287.zip |
add bref augment scaffold
Diffstat (limited to 'skate')
-rw-r--r-- | skate/reduce_test.go | 40 | ||||
-rw-r--r-- | skate/testdata/zippy/cB00a.json | 1 | ||||
-rw-r--r-- | skate/testdata/zippy/cB00b.json | 1 | ||||
-rw-r--r-- | skate/testdata/zippy/cB00r.json | 1 |
4 files changed, 43 insertions, 0 deletions
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"} |